Socket
Socket
Sign inDemoInstall

event-from

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    event-from

Determine if an event was caused by mouse, touch or key input.


Version published
Maintainers
1
Install size
1.50 kB
Created

Readme

Source

⚠️⚠️ Under Construction - Not Operational ⚠️⚠️

Event From

Determine if a DOM Event was caused by mouse, touch, or key input.

npm install --save event-from
import { eventFrom } from "event-from";

// event is any DOM Event
eventFrom(event): "mouse" | "touch" | "key";

Ignore MouseEvents that were caused by touch input

import { eventFrom } from "event-from";

const handleMouseEnter = (e) => {
  if (eventFrom(e) !== "mouse") return;
  // code for handling mouse enter event from mouse input
};

element.addEventListener("mouseenter", handleMouseEnter, false);

Determine if a FocusEvent was caused by key input for accessibility

import { eventFrom } from "event-from";

const handleFocus = (e) => {
  if (eventFrom(e) === "key") {
    // set focus styles for accessibility from keyboard input
  }
};

FAQs

Last updated on 20 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc