pax_global_header00006660000000000000000000000064142727142700014520gustar00rootroot0000000000000052 comment=70833bb8ac7e9be92635bc0544d1c25fccb4fea3 w3c-keyname-2.2.6/000077500000000000000000000000001427271427000136525ustar00rootroot00000000000000w3c-keyname-2.2.6/.gitignore000066400000000000000000000000411427271427000156350ustar00rootroot00000000000000/node_modules .tern-* /index.cjs w3c-keyname-2.2.6/.npmignore000066400000000000000000000000401427271427000156430ustar00rootroot00000000000000node_modules/ rollup.config.js w3c-keyname-2.2.6/LICENSE000066400000000000000000000021061427271427000146560ustar00rootroot00000000000000Copyright (C) 2016 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. w3c-keyname-2.2.6/README.md000066400000000000000000000013371427271427000151350ustar00rootroot00000000000000# W3C keyname Tiny library that exports a function `keyName` that takes a keyboard event and returns a [`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)-style string. Will use the actual `key` property of the event if available, and fall back to a value synthesized from the `keyCode` otherwise. Probably often wrong on non-US keyboards, since the correspondence between a key code and the character it produces when shift is held is predicted based on a hard-coded table. Meant as a fallback for `KeyboardEvent.key`, not a replacement. The lookup tables from key codes (`event.keyCode`) to names are exported as `base` (when Shift isn't held) and `shift` (when Shift is held). License: MIT w3c-keyname-2.2.6/index.d.ts000066400000000000000000000002221427271427000155470ustar00rootroot00000000000000export function keyName(event: Event): string; export const base: {[keyCode: number]: string}; export const shift: {[keyCode: number]: string}; w3c-keyname-2.2.6/index.es.js000066400000000000000000000052341427271427000157310ustar00rootroot00000000000000export var base = { 8: "Backspace", 9: "Tab", 10: "Enter", 12: "NumLock", 13: "Enter", 16: "Shift", 17: "Control", 18: "Alt", 20: "CapsLock", 27: "Escape", 32: " ", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "ArrowLeft", 38: "ArrowUp", 39: "ArrowRight", 40: "ArrowDown", 44: "PrintScreen", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Meta", 92: "Meta", 106: "*", 107: "+", 108: ",", 109: "-", 110: ".", 111: "/", 144: "NumLock", 145: "ScrollLock", 160: "Shift", 161: "Shift", 162: "Control", 163: "Control", 164: "Alt", 165: "Alt", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'" } export var shift = { 48: ")", 49: "!", 50: "@", 51: "#", 52: "$", 53: "%", 54: "^", 55: "&", 56: "*", 57: "(", 59: ":", 61: "+", 173: "_", 186: ":", 187: "+", 188: "<", 189: "_", 190: ">", 191: "?", 192: "~", 219: "{", 220: "|", 221: "}", 222: "\"" } var chrome = typeof navigator != "undefined" && /Chrome\/(\d+)/.exec(navigator.userAgent) var gecko = typeof navigator != "undefined" && /Gecko\/\d+/.test(navigator.userAgent) var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform) var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent) var brokenModifierNames = mac || chrome && +chrome[1] < 57 // Fill in the digit keys for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i) // The function keys for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i // And the alphabetic keys for (var i = 65; i <= 90; i++) { base[i] = String.fromCharCode(i + 32) shift[i] = String.fromCharCode(i) } // For each code that doesn't have a shift-equivalent, copy the base name for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code] export function keyName(event) { var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified" var name = (!ignoreKey && event.key) || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified" // Edge sometimes produces wrong names (Issue #3) if (name == "Esc") name = "Escape" if (name == "Del") name = "Delete" // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/ if (name == "Left") name = "ArrowLeft" if (name == "Up") name = "ArrowUp" if (name == "Right") name = "ArrowRight" if (name == "Down") name = "ArrowDown" return name } w3c-keyname-2.2.6/package.json000066400000000000000000000015121427271427000161370ustar00rootroot00000000000000{ "name": "w3c-keyname", "version": "2.2.6", "description": "Get a KeyboardEvent.key-style string from an event", "main": "index.cjs", "type": "module", "exports": { "import": "./index.es.js", "require": "./index.cjs" }, "module": "index.es.js", "types": "index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/marijnh/w3c-keyname.git" }, "keywords": [ "browser", "key", "event", "key code" ], "author": "Marijn Haverbeke ", "license": "MIT", "bugs": { "url": "https://github.com/marijnh/w3c-keyname/issues" }, "homepage": "https://github.com/marijnh/w3c-keyname#readme", "scripts": { "build": "rollup -c", "watch": "rollup -c -w", "prepare": "npm run build" }, "devDependencies": { "rollup": "^1.26.3" } } w3c-keyname-2.2.6/rollup.config.js000066400000000000000000000001441427271427000167700ustar00rootroot00000000000000export default { input: "index.es.js", output: { file: "index.cjs", format: "cjs" } }