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.0.2 to 0.0.3

38

lib/index.js

@@ -92,4 +92,12 @@ 'use strict';

var values = hotkey.split('+');
var length = values.length;
var ret = {};
// Ensure that any modifier that isn't explicitly set is set to `false`.
for (var k in MODIFIERS) {
var m = MODIFIERS[k];
ret[m] = false;
}
var _iteratorNormalCompletion = true;

@@ -103,3 +111,2 @@ var _didIteratorError = false;

var _key = void 0;
value = value.toLowerCase();

@@ -115,12 +122,18 @@

if (values.length == 1) {
var _m = MODIFIERS[value];
if (length == 1 || !_m) {
ret.key = value;
} else if (value in MODIFIERS) {
var _key2 = MODIFIERS[value];
ret[_key2] = true;
}
if (_m) {
ret[_m] = true;
}
// If there's only one key, and it's not a modifier, ignore the shift key
// because it will already be taken into accout by the `event.key` value.
if (length == 1 && !_m) {
ret.shiftKey = null;
}
}
// Ensure that any modifier that isn't explicitly set is set to `false`,
// unless the hotkey is only matching a single key.
} catch (err) {

@@ -141,9 +154,2 @@ _didIteratorError = true;

if (values.length != 1) {
for (var k in MODIFIERS) {
var key = MODIFIERS[k];
if (!(key in ret)) ret[key] = false;
}
}
return ret;

@@ -164,3 +170,3 @@ }

var expected = object[key];
if (actual != expected) return false;
if (expected != null && actual != expected) return false;
}

@@ -167,0 +173,0 @@

{
"name": "is-hotkey",
"description": "Check whether a browser event matches a hotkey.",
"version": "0.0.2",
"version": "0.0.3",
"license": "MIT",

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

@@ -94,6 +94,12 @@

const values = hotkey.split('+')
const { length } = values
const ret = {}
// Ensure that any modifier that isn't explicitly set is set to `false`.
for (const k in MODIFIERS) {
const m = MODIFIERS[k]
ret[m] = false
}
for (let value of values) {
let key
value = value.toLowerCase()

@@ -109,17 +115,17 @@

if (values.length == 1) {
const m = MODIFIERS[value]
if (length == 1 || !m) {
ret.key = value
} else if (value in MODIFIERS) {
const key = MODIFIERS[value]
ret[key] = true
}
}
// Ensure that any modifier that isn't explicitly set is set to `false`,
// unless the hotkey is only matching a single key.
if (values.length != 1) {
for (const k in MODIFIERS) {
const key = MODIFIERS[k]
if (!(key in ret)) ret[key] = false
if (m) {
ret[m] = true
}
// If there's only one key, and it's not a modifier, ignore the shift key
// because it will already be taken into accout by the `event.key` value.
if (length == 1 && !m) {
ret.shiftKey = null
}
}

@@ -142,3 +148,3 @@

const expected = object[key]
if (actual != expected) return false
if (expected != null && actual != expected) return false
}

@@ -145,0 +151,0 @@

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