Socket
Socket
Sign inDemoInstall

is-hotkey

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-hotkey - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

10

lib/index.js

@@ -103,2 +103,10 @@ 'use strict';

function isCodeHotkey(hotkey, event) {
return isHotkey(hotkey, event);
}
function isKeyHotkey(hotkey, event) {
return isHotkey(hotkey, { byKey: true }, event);
}
/**

@@ -217,2 +225,4 @@ * Parse.

exports.isHotkey = isHotkey;
exports.isCodeHotkey = isCodeHotkey;
exports.isKeyHotkey = isKeyHotkey;
exports.parseHotkey = parseHotkey;

@@ -219,0 +229,0 @@ exports.compareHotkey = compareHotkey;

2

package.json
{
"name": "is-hotkey",
"description": "Check whether a browser event matches a hotkey.",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "git://github.com/ianstormtaylor/is-hotkey.git",

@@ -88,4 +88,17 @@

```js
import isHotkey from 'is-hotkey'
import { isCodeHotkey, isKeyHotkey } from 'is-hotkey'
isHotkey('mod+s')(event)
isHotkey('mod+s', { byKey: true })(event)
isCodeHotkey('mod+s', event)
isKeyHotkey('mod+s', event)
```
By default the hotkey string is checked using `event.which`. But you can also pass in `byKey: true` to compare using the [`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) API, which stays the same regardless of keyboard layout.
Or to reduce the noise if you are defining lots of hotkeys, you can use the `isCodeHotkey` and `isKeyHotkey` helpers that are exported.
```js

@@ -92,0 +105,0 @@ import { toKeyName, toKeyCode } from 'is-hotkey'

@@ -101,2 +101,10 @@

function isCodeHotkey(hotkey, event) {
return isHotkey(hotkey, event)
}
function isKeyHotkey(hotkey, event) {
return isHotkey(hotkey, { byKey: true }, event)
}
/**

@@ -195,2 +203,4 @@ * Parse.

isHotkey,
isCodeHotkey,
isKeyHotkey,
parseHotkey,

@@ -197,0 +207,0 @@ compareHotkey,

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc