Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@lumino/keyboard

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumino/keyboard - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

41

dist/index.es6.js

@@ -51,7 +51,11 @@ // Copyright (c) Jupyter Development Team.

* @param codes - A mapping of keycode to key value.
*
* @param modifierKeys - Array of modifier key names
*/
function KeycodeLayout(name, codes) {
function KeycodeLayout(name, codes, modifierKeys) {
if (modifierKeys === void 0) { modifierKeys = []; }
this.name = name;
this._codes = codes;
this._keys = KeycodeLayout.extractKeys(codes);
this._modifierKeys = KeycodeLayout.convertToKeySet(modifierKeys);
}

@@ -77,2 +81,12 @@ /**

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*/
KeycodeLayout.prototype.isModifierKey = function (key) {
return key in this._modifierKeys;
};
/**
* Get the key for a `'keydown'` event.

@@ -109,2 +123,17 @@ *

KeycodeLayout.extractKeys = extractKeys;
/**
* Convert array of keys to a key set.
*
* @param keys - The array that needs to be converted
*
* @returns A set of the keys in the array.
*/
function convertToKeySet(keys) {
var keySet = Object(null);
for (var i = 0, n = keys.length; i < n; ++i) {
keySet[keys[i]] = true;
}
return keySet;
}
KeycodeLayout.convertToKeySet = convertToKeySet;
})(KeycodeLayout || (KeycodeLayout = {}));

@@ -136,2 +165,5 @@ /**

13: 'Enter',
16: 'Shift',
17: 'Ctrl',
18: 'Alt',
19: 'Pause',

@@ -188,2 +220,3 @@ 27: 'Escape',

90: 'Z',
91: 'Meta',
93: 'ContextMenu',

@@ -228,4 +261,6 @@ 96: '0',

221: ']',
222: "'"
});
222: "'",
224: 'Meta' // firefox
}, ['Shift', 'Ctrl', 'Alt', 'Meta'] // modifier keys
);
/**

@@ -232,0 +267,0 @@ * The namespace for the module implementation details.

@@ -57,7 +57,11 @@ (function (global, factory) {

* @param codes - A mapping of keycode to key value.
*
* @param modifierKeys - Array of modifier key names
*/
function KeycodeLayout(name, codes) {
function KeycodeLayout(name, codes, modifierKeys) {
if (modifierKeys === void 0) { modifierKeys = []; }
this.name = name;
this._codes = codes;
this._keys = KeycodeLayout.extractKeys(codes);
this._modifierKeys = KeycodeLayout.convertToKeySet(modifierKeys);
}

@@ -83,2 +87,12 @@ /**

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*/
KeycodeLayout.prototype.isModifierKey = function (key) {
return key in this._modifierKeys;
};
/**
* Get the key for a `'keydown'` event.

@@ -115,2 +129,17 @@ *

KeycodeLayout.extractKeys = extractKeys;
/**
* Convert array of keys to a key set.
*
* @param keys - The array that needs to be converted
*
* @returns A set of the keys in the array.
*/
function convertToKeySet(keys) {
var keySet = Object(null);
for (var i = 0, n = keys.length; i < n; ++i) {
keySet[keys[i]] = true;
}
return keySet;
}
KeycodeLayout.convertToKeySet = convertToKeySet;
})(exports.KeycodeLayout || (exports.KeycodeLayout = {}));

@@ -142,2 +171,5 @@ /**

13: 'Enter',
16: 'Shift',
17: 'Ctrl',
18: 'Alt',
19: 'Pause',

@@ -194,2 +226,3 @@ 27: 'Escape',

90: 'Z',
91: 'Meta',
93: 'ContextMenu',

@@ -234,4 +267,6 @@ 96: '0',

221: ']',
222: "'"
});
222: "'",
224: 'Meta' // firefox
}, ['Shift', 'Ctrl', 'Alt', 'Meta'] // modifier keys
);
/**

@@ -238,0 +273,0 @@ * The namespace for the module implementation details.

2

dist/index.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_keyboard={})}(this,(function(e){"use strict";e.KeycodeLayout=function(){function e(t,o){this.name=t,this._codes=o,this._keys=e.extractKeys(o)}return e.prototype.keys=function(){return Object.keys(this._keys)},e.prototype.isValidKey=function(e){return e in this._keys},e.prototype.keyForKeydownEvent=function(e){return this._codes[e.keyCode]||""},e}(),(e.KeycodeLayout||(e.KeycodeLayout={})).extractKeys=function(e){var t=Object.create(null);for(var o in e)t[e[o]]=!0;return t};var t,o=new e.KeycodeLayout("en-us",{8:"Backspace",9:"Tab",13:"Enter",19:"Pause",27:"Escape",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",93:"ContextMenu",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"});!function(e){e.keyboardLayout=o}(t||(t={})),e.EN_US=o,e.getKeyboardLayout=function(){return t.keyboardLayout},e.setKeyboardLayout=function(e){t.keyboardLayout=e},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lumino_keyboard={})}(this,(function(e){"use strict";var t;e.KeycodeLayout=function(){function e(t,o,n){void 0===n&&(n=[]),this.name=t,this._codes=o,this._keys=e.extractKeys(o),this._modifierKeys=e.convertToKeySet(n)}return e.prototype.keys=function(){return Object.keys(this._keys)},e.prototype.isValidKey=function(e){return e in this._keys},e.prototype.isModifierKey=function(e){return e in this._modifierKeys},e.prototype.keyForKeydownEvent=function(e){return this._codes[e.keyCode]||""},e}(),(t=e.KeycodeLayout||(e.KeycodeLayout={})).extractKeys=function(e){var t=Object.create(null);for(var o in e)t[e[o]]=!0;return t},t.convertToKeySet=function(e){for(var t=Object(null),o=0,n=e.length;o<n;++o)t[e[o]]=!0;return t};var o,n=new e.KeycodeLayout("en-us",{8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",27:"Escape",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",91:"Meta",93:"ContextMenu",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Meta"},["Shift","Ctrl","Alt","Meta"]);!function(e){e.keyboardLayout=n}(o||(o={})),e.EN_US=n,e.getKeyboardLayout=function(){return o.keyboardLayout},e.setKeyboardLayout=function(e){o.keyboardLayout=e},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.min.js.map
{
"name": "@lumino/keyboard",
"version": "1.7.0",
"version": "1.8.0",
"description": "Lumino Keyboard",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/jupyterlab/lumino",

@@ -43,2 +43,18 @@ // Copyright (c) Jupyter Development Team.

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*
* #### Notes
* This is necessary so that we don't process modifier keys pressed
* in the middle of the key sequence.
* E.g. "Shift C Ctrl P" is actually 4 keydown events:
* "Shift", "Shift P", "Ctrl", "Ctrl P",
* and events for "Shift" and "Ctrl" should be ignored.
*/
isModifierKey(key: string): boolean;
/**
* Get the key for a `'keydown'` event.

@@ -97,7 +113,14 @@ *

* @param codes - A mapping of keycode to key value.
*
* @param modifierKeys - Array of modifier key names
*/
constructor(name: string, codes: KeycodeLayout.CodeMap) {
constructor(
name: string,
codes: KeycodeLayout.CodeMap,
modifierKeys: string[] = []
) {
this.name = name;
this._codes = codes;
this._keys = KeycodeLayout.extractKeys(codes);
this._modifierKeys = KeycodeLayout.convertToKeySet(modifierKeys);
}

@@ -131,2 +154,13 @@

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*/
isModifierKey(key: string): boolean {
return key in this._modifierKeys;
}
/**
* Get the key for a `'keydown'` event.

@@ -145,2 +179,3 @@ *

private _codes: KeycodeLayout.CodeMap;
private _modifierKeys: KeycodeLayout.KeySet;
}

@@ -176,2 +211,17 @@

}
/**
* Convert array of keys to a key set.
*
* @param keys - The array that needs to be converted
*
* @returns A set of the keys in the array.
*/
export function convertToKeySet(keys: string[]): KeySet {
let keySet = Object(null);
for (let i = 0, n = keys.length; i < n; ++i) {
keySet[keys[i]] = true;
}
return keySet;
}
}

@@ -200,98 +250,107 @@

*/
export const EN_US: IKeyboardLayout = new KeycodeLayout('en-us', {
8: 'Backspace',
9: 'Tab',
13: 'Enter',
19: 'Pause',
27: 'Escape',
32: 'Space',
33: 'PageUp',
34: 'PageDown',
35: 'End',
36: 'Home',
37: 'ArrowLeft',
38: 'ArrowUp',
39: 'ArrowRight',
40: 'ArrowDown',
45: 'Insert',
46: 'Delete',
48: '0',
49: '1',
50: '2',
51: '3',
52: '4',
53: '5',
54: '6',
55: '7',
56: '8',
57: '9',
59: ';', // firefox
61: '=', // firefox
65: 'A',
66: 'B',
67: 'C',
68: 'D',
69: 'E',
70: 'F',
71: 'G',
72: 'H',
73: 'I',
74: 'J',
75: 'K',
76: 'L',
77: 'M',
78: 'N',
79: 'O',
80: 'P',
81: 'Q',
82: 'R',
83: 'S',
84: 'T',
85: 'U',
86: 'V',
87: 'W',
88: 'X',
89: 'Y',
90: 'Z',
93: 'ContextMenu',
96: '0', // numpad
97: '1', // numpad
98: '2', // numpad
99: '3', // numpad
100: '4', // numpad
101: '5', // numpad
102: '6', // numpad
103: '7', // numpad
104: '8', // numpad
105: '9', // numpad
106: '*', // numpad
107: '+', // numpad
109: '-', // numpad
110: '.', // numpad
111: '/', // numpad
112: 'F1',
113: 'F2',
114: 'F3',
115: 'F4',
116: 'F5',
117: 'F6',
118: 'F7',
119: 'F8',
120: 'F9',
121: 'F10',
122: 'F11',
123: 'F12',
173: '-', // firefox
186: ';', // non-firefox
187: '=', // non-firefox
188: ',',
189: '-', // non-firefox
190: '.',
191: '/',
192: '`',
219: '[',
220: '\\',
221: ']',
222: "'"
});
export const EN_US: IKeyboardLayout = new KeycodeLayout(
'en-us',
{
8: 'Backspace',
9: 'Tab',
13: 'Enter',
16: 'Shift',
17: 'Ctrl',
18: 'Alt',
19: 'Pause',
27: 'Escape',
32: 'Space',
33: 'PageUp',
34: 'PageDown',
35: 'End',
36: 'Home',
37: 'ArrowLeft',
38: 'ArrowUp',
39: 'ArrowRight',
40: 'ArrowDown',
45: 'Insert',
46: 'Delete',
48: '0',
49: '1',
50: '2',
51: '3',
52: '4',
53: '5',
54: '6',
55: '7',
56: '8',
57: '9',
59: ';', // firefox
61: '=', // firefox
65: 'A',
66: 'B',
67: 'C',
68: 'D',
69: 'E',
70: 'F',
71: 'G',
72: 'H',
73: 'I',
74: 'J',
75: 'K',
76: 'L',
77: 'M',
78: 'N',
79: 'O',
80: 'P',
81: 'Q',
82: 'R',
83: 'S',
84: 'T',
85: 'U',
86: 'V',
87: 'W',
88: 'X',
89: 'Y',
90: 'Z',
91: 'Meta', // non-firefox
93: 'ContextMenu',
96: '0', // numpad
97: '1', // numpad
98: '2', // numpad
99: '3', // numpad
100: '4', // numpad
101: '5', // numpad
102: '6', // numpad
103: '7', // numpad
104: '8', // numpad
105: '9', // numpad
106: '*', // numpad
107: '+', // numpad
109: '-', // numpad
110: '.', // numpad
111: '/', // numpad
112: 'F1',
113: 'F2',
114: 'F3',
115: 'F4',
116: 'F5',
117: 'F6',
118: 'F7',
119: 'F8',
120: 'F9',
121: 'F10',
122: 'F11',
123: 'F12',
173: '-', // firefox
186: ';', // non-firefox
187: '=', // non-firefox
188: ',',
189: '-', // non-firefox
190: '.',
191: '/',
192: '`',
219: '[',
220: '\\',
221: ']',
222: "'",
224: 'Meta' // firefox
},
['Shift', 'Ctrl', 'Alt', 'Meta'] // modifier keys
);

@@ -298,0 +357,0 @@ /**

@@ -30,2 +30,17 @@ /**

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*
* #### Notes
* This is necessary so that we don't process modifier keys pressed
* in the middle of the key sequence.
* E.g. "Shift C Ctrl P" is actually 4 keydown events:
* "Shift", "Shift P", "Ctrl", "Ctrl P",
* and events for "Shift" and "Ctrl" should be ignored.
*/
isModifierKey(key: string): boolean;
/**
* Get the key for a `'keydown'` event.

@@ -77,4 +92,6 @@ *

* @param codes - A mapping of keycode to key value.
*
* @param modifierKeys - Array of modifier key names
*/
constructor(name: string, codes: KeycodeLayout.CodeMap);
constructor(name: string, codes: KeycodeLayout.CodeMap, modifierKeys?: string[]);
/**

@@ -99,2 +116,10 @@ * The human readable name of the layout.

/**
* Test whether the given key is a modifier key.
*
* @param key - The user provided key.
*
* @returns `true` if the key is a modifier key, `false` otherwise.
*/
isModifierKey(key: string): boolean;
/**
* Get the key for a `'keydown'` event.

@@ -110,2 +135,3 @@ *

private _codes;
private _modifierKeys;
}

@@ -136,2 +162,10 @@ /**

function extractKeys(codes: CodeMap): KeySet;
/**
* Convert array of keys to a key set.
*
* @param keys - The array that needs to be converted
*
* @returns A set of the keys in the array.
*/
function convertToKeySet(keys: string[]): KeySet;
}

@@ -138,0 +172,0 @@ /**

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

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