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

ctrl-keys

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ctrl-keys - npm Package Compare versions

Comparing version 1.0.1-alpha to 1.0.2-alpha

16

dist/index.d.ts

@@ -5,2 +5,11 @@ import { Join, SubArray, MutableTuple } from "just-types";

declare const modifiers: readonly ["ctrl", "alt", "meta", "shift"];
declare const aliases: {
readonly space: " ";
readonly plus: "+";
readonly up: "arrowup";
readonly down: "arrowdown";
readonly left: "arrowleft";
readonly right: "arrowright";
readonly esc: "escape";
};
declare const codes: Record<string, number>;

@@ -19,2 +28,3 @@ export type Modifiers = MutableTuple<typeof modifiers>;

export type Callback = () => any;
export type KeyboardEventListener = (event: KeyboardEvent) => any;
export type HandlerState<KA extends KeyAliases = {}> = {

@@ -26,2 +36,3 @@ codes: Record<string, EncodedKey>;

bindings: Map<EncodedSequence, Set<Callback>>;
targets: Set<EventTarget>;
};

@@ -40,6 +51,9 @@ export interface HandlerInterface<KA extends KeyAliases = {}> {

remove(keys: StringKey<Aliases> | Array<StringKey<Aliases>>, fn: Callback): this;
addListener(target: EventTarget): this;
removeListener(target: EventTarget): this;
handle(event: KeyboardEvent): this;
}
export function handler<Aliases extends KeyAliases>(state?: Partial<HandlerState<Aliases>>): Handler<Aliases>;
type DefaultAliases = typeof aliases;
export function createHandler<Aliases extends KeyAliases = DefaultAliases>(customAliases?: Aliases): Handler<Aliases>;
//# sourceMappingURL=index.d.ts.map

48

dist/index.js

@@ -21,3 +21,3 @@ function $parcel$export(e, n, v, s) {

$parcel$export(module.exports, "handler", () => $aa45dd47f927307f$export$c3c52e219617878);
$parcel$export(module.exports, "createHandler", () => $aa45dd47f927307f$export$b28d6921b4a85ec4);
var $2ae344e2615bfe7e$exports = {};

@@ -505,4 +505,2 @@ const $d4d671800b8e9ae0$export$30a86d91af8ff6e6 = [

const key = $b0dd6840dedf4baf$export$81dbaac8d5335cb6(state.codes, event);
const lastKey = state.history.pop();
if (lastKey !== undefined && !$b32bc79731ce4566$export$dfb8e737f14c75a8(lastKey, key)) state.history.push(lastKey);
state.history.push(key);

@@ -518,7 +516,12 @@ if (state.history.length > state.historySize) state.history.shift();

}
function $b32bc79731ce4566$export$dfb8e737f14c75a8(oldKey, newKey) {
if ($b0dd6840dedf4baf$export$d95305c1c4c40d1d(oldKey) > 0) return false;
const oldModifiers = $b0dd6840dedf4baf$export$a10907c21fef597b(oldKey);
return (oldModifiers & $b0dd6840dedf4baf$export$a10907c21fef597b(newKey)) == oldModifiers;
function $b32bc79731ce4566$export$9dd68fe78f37278b(state, target, handle) {
target.addEventListener('keyup', handle);
state.targets.add(target);
return state;
}
function $b32bc79731ce4566$export$20ae7ec87f7f8696(state, target, handle) {
target.removeEventListener('keyup', handle);
state.targets.delete(target);
return state;
}

@@ -541,2 +544,10 @@

}
addListener(target) {
this.state = $b32bc79731ce4566$export$9dd68fe78f37278b(this.state, target, this.handle);
return this;
}
removeListener(target1) {
this.state = $b32bc79731ce4566$export$20ae7ec87f7f8696(this.state, target1, this.handle);
return this;
}
handle(event) {

@@ -548,2 +559,7 @@ this.state = $b32bc79731ce4566$export$d6e5ca10785815df(this.state, event);

this.state = state;
this.add = this.add.bind(this);
this.remove = this.remove.bind(this);
this.addListener = this.addListener.bind(this);
this.removeListener = this.removeListener.bind(this);
this.handle = this.handle.bind(this);
}

@@ -553,14 +569,10 @@ }

const $aa45dd47f927307f$var$defaultState = {
codes: $5b7d139e954bac1f$export$e45cb6485273080e,
aliases: $5b7d139e954bac1f$export$9af93bb9e9126a2,
history: [],
historySize: 0,
bindings: new Map()
};
function $aa45dd47f927307f$export$c3c52e219617878(state = {
}) {
function $aa45dd47f927307f$export$b28d6921b4a85ec4(customAliases) {
return new $6a5631b959ebf7d3$export$a428cd33b25d5283({
...$aa45dd47f927307f$var$defaultState,
...state
codes: $5b7d139e954bac1f$export$e45cb6485273080e,
aliases: customAliases || $5b7d139e954bac1f$export$9af93bb9e9126a2,
history: [],
historySize: 0,
bindings: new Map(),
targets: new Set()
});

@@ -567,0 +579,0 @@ }

@@ -483,4 +483,2 @@ var $b289af7168eb38ef$exports = {};

const key = $43bfee6ae65bc01f$export$81dbaac8d5335cb6(state.codes, event);
const lastKey = state.history.pop();
if (lastKey !== undefined && !$7ce5330ea363ecfa$export$dfb8e737f14c75a8(lastKey, key)) state.history.push(lastKey);
state.history.push(key);

@@ -496,7 +494,12 @@ if (state.history.length > state.historySize) state.history.shift();

}
function $7ce5330ea363ecfa$export$dfb8e737f14c75a8(oldKey, newKey) {
if ($43bfee6ae65bc01f$export$d95305c1c4c40d1d(oldKey) > 0) return false;
const oldModifiers = $43bfee6ae65bc01f$export$a10907c21fef597b(oldKey);
return (oldModifiers & $43bfee6ae65bc01f$export$a10907c21fef597b(newKey)) == oldModifiers;
function $7ce5330ea363ecfa$export$9dd68fe78f37278b(state, target, handle) {
target.addEventListener('keyup', handle);
state.targets.add(target);
return state;
}
function $7ce5330ea363ecfa$export$20ae7ec87f7f8696(state, target, handle) {
target.removeEventListener('keyup', handle);
state.targets.delete(target);
return state;
}

@@ -519,2 +522,10 @@

}
addListener(target) {
this.state = $7ce5330ea363ecfa$export$9dd68fe78f37278b(this.state, target, this.handle);
return this;
}
removeListener(target1) {
this.state = $7ce5330ea363ecfa$export$20ae7ec87f7f8696(this.state, target1, this.handle);
return this;
}
handle(event) {

@@ -526,2 +537,7 @@ this.state = $7ce5330ea363ecfa$export$d6e5ca10785815df(this.state, event);

this.state = state;
this.add = this.add.bind(this);
this.remove = this.remove.bind(this);
this.addListener = this.addListener.bind(this);
this.removeListener = this.removeListener.bind(this);
this.handle = this.handle.bind(this);
}

@@ -531,14 +547,10 @@ }

const $d4d3b83ce2175773$var$defaultState = {
codes: $32cb1e6563700bfb$export$e45cb6485273080e,
aliases: $32cb1e6563700bfb$export$9af93bb9e9126a2,
history: [],
historySize: 0,
bindings: new Map()
};
function $d4d3b83ce2175773$export$c3c52e219617878(state = {
}) {
function $d4d3b83ce2175773$export$b28d6921b4a85ec4(customAliases) {
return new $dd433ca0ced25dee$export$a428cd33b25d5283({
...$d4d3b83ce2175773$var$defaultState,
...state
codes: $32cb1e6563700bfb$export$e45cb6485273080e,
aliases: customAliases || $32cb1e6563700bfb$export$9af93bb9e9126a2,
history: [],
historySize: 0,
bindings: new Map(),
targets: new Set()
});

@@ -550,3 +562,3 @@ }

export {$d4d3b83ce2175773$export$c3c52e219617878 as handler};
export {$d4d3b83ce2175773$export$b28d6921b4a85ec4 as createHandler};
//# sourceMappingURL=module.js.map
{
"name": "ctrl-keys",
"author": "Amine Ben hammou",
"description": "A library to handle keybindings.",
"description": "A Typescript library to handle keybindings efficiently.",
"license": "MIT",
"version": "1.0.1-alpha",
"version": "1.0.2-alpha",
"source": "src/index.ts",

@@ -25,2 +25,4 @@ "main": "dist/index.js",

"@parcel/transformer-typescript-types": "^2.0.1",
"@testing-library/dom": "^8.11.1",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.0.2",

@@ -27,0 +29,0 @@ "jest": "^27.3.1",

# ctrl-keys
A library to handle keybindings.
A Typescript library to handle keybindings efficiently.

@@ -11,2 +11,3 @@ [![Bundle size](https://img.shields.io/bundlephobia/minzip/ctrl-keys?style=flat-square)](https://bundlephobia.com/result?p=ctrl-keys)

[![Version](https://img.shields.io/npm/v/ctrl-keys?style=flat-square)](https://www.npmjs.com/package/ctrl-keys)
[![MIT](https://img.shields.io/npm/l/ctrl-keys?style=flat-square)](LICENSE)
[![MIT](https://img.shields.io/npm/l/ctrl-keys?style=flat-square)](LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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