New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

combokeys-capture

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

combokeys-capture - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

14

Combokeys/index.js

@@ -16,17 +16,9 @@ /* eslint-env node, browser */

/**
* direct map of string combinations to callbacks used for trigger()
* keeps track of active sequences
*
* @type {Object}
* @type {Array}
*/
self.directMap = {};
self.activeSequences = [];
/**
* keeps track of what level each sequence is at since multiple
* sequences can start out with the same sequence
*
* @type {Object}
*/
self.sequenceLevels = {};
/**
* variable to store the setTimeout call

@@ -33,0 +25,0 @@ *

@@ -18,3 +18,3 @@ /* eslint-env node, browser */

// and setting the level to 0
self.sequenceLevels[combo] = 0;
callback.currentLevel = 0;

@@ -31,4 +31,6 @@ /**

self.nextExpectedAction = nextAction;
++self.sequenceLevels[combo];
++callback.currentLevel;
self.resetSequenceTimer();
return true;
};

@@ -80,3 +82,3 @@ }

var wrappedCallback = isFinal ? callbackAndReset : increaseSequence(action || self.getKeyInfo(keys[j + 1]).action);
unbinders.push(self.bindSingle(keys[j], wrappedCallback, action, combo, j));
unbinders.push(self.bindSingle(keys[j], wrappedCallback, action, combo, j, callback));
}

@@ -83,0 +85,0 @@

@@ -14,3 +14,3 @@ /* eslint-env node, browser */

*/
module.exports = function (combination, callback, action, sequenceName, level) {
module.exports = function (combination, callback, action, sequenceName, level, originalCallback) {
var self = this;

@@ -46,2 +46,3 @@

callback: callback,
originalCallback: originalCallback || callback,
modifiers: info.modifiers,

@@ -48,0 +49,0 @@ action: info.action,

@@ -21,6 +21,7 @@ /* eslint-env node, browser */

if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
return;
return true;
}
if (callback(e, combo) === false) {
var callbackReturnValue = callback(e, combo);
if (callbackReturnValue === false) {
preventDefault = require("../../helpers/preventDefault");

@@ -31,2 +32,4 @@ preventDefault(e);

}
return callbackReturnValue;
};

@@ -38,3 +38,3 @@ /* eslint-env node, browser */

// and see if any of them match
var callbacks = self.callbacks[character].sequences.reverse().concat(self.callbacks[character].singles.reverse());
var callbackDefinitions = self.callbacks[character].sequences.reverse().concat(self.callbacks[character].singles.reverse());

@@ -45,8 +45,8 @@ //stupid reverse function mutates array

for (j = 0; j < callbacks.length; ++j) {
callback = callbacks[j];
for (j = 0; j < callbackDefinitions.length; ++j) {
var callbackDefinition = callbackDefinitions[j];
// if a sequence name is not specified, but this is a sequence at
// the wrong level then move onto the next match
if (!sequenceName && callback.seq && self.sequenceLevels[callback.seq] !== callback.level) {
if (!sequenceName && callbackDefinition.seq && callbackDefinition.originalCallback.currentLevel !== callbackDefinition.level) {
continue;

@@ -57,3 +57,3 @@ }

// then we should keep going
if (action !== callback.action) {
if (action !== callbackDefinition.action) {
continue;

@@ -70,4 +70,4 @@ }

modifiersMatch = require("./modifiersMatch");
if ((action === "keypress" && !e.metaKey && !e.ctrlKey) || modifiersMatch(modifiers, callback.modifiers)) {
matches.push(callback);
if ((action === "keypress" && !e.metaKey && !e.ctrlKey) || modifiersMatch(modifiers, callbackDefinition.modifiers)) {
matches.push(callbackDefinition);
}

@@ -74,0 +74,0 @@ }

@@ -16,3 +16,3 @@ /* eslint-env node, browser */

j,
doNotReset = {},
activeSequences = [],
maxLevel = 0,

@@ -56,4 +56,8 @@ processedSequenceCallback = false,

// keep a list of which sequences were matches for later
doNotReset[callbacks[j].seq] = 1;
self.fireCallback(callbacks[j].callback, e, callbacks[j].combo, callbacks[j].seq);
activeSequences.push(callbacks[j].originalCallback);
if(!self.fireCallback(callbacks[j].callback, e, callbacks[j].combo, callbacks[j].seq)){
//wrapped function to increment counter returns true
activeSequences = [];
break;
}
continue;

@@ -93,3 +97,3 @@ }

if (e.type === self.nextExpectedAction && !isModifier(character) && !ignoreThisKeypress) {
self.resetSequences(doNotReset);
self.resetSequences(activeSequences);
}

@@ -96,0 +100,0 @@

@@ -10,21 +10,15 @@ /* eslint-env node, browser */

*/
module.exports = function (doNotReset) {
var self = this;
module.exports = function (activeSequences) {
activeSequences = activeSequences || [];
doNotReset = doNotReset || {};
var activeSequences = false,
key;
for (key in self.sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true;
continue;
for(var key in this.callbacks){
var callbackDefinitions = this.callbacks[key].sequences;
for(var ii=0; ii<callbackDefinitions.length; ii++){
if(activeSequences.indexOf(callbackDefinitions[ii].originalCallback) === -1){
callbackDefinitions[ii].originalCallback.currentLevel = 0;
}
}
self.sequenceLevels[key] = 0;
}
if (!activeSequences) {
self.nextExpectedAction = false;
}
this.nextExpectedAction = activeSequences.length > 0;
};
{
"name": "combokeys-capture",
"version": "2.4.1",
"version": "2.4.2",
"description": "JavaScript library for handling keyboard shortcuts in the browser",

@@ -5,0 +5,0 @@ "main": "index.js",

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