@github/hotkey
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -6,4 +6,4 @@ import { NormalizedSequenceString } from './sequence'; | ||
}; | ||
export declare function eventToHotkeyString(event: KeyboardEvent): NormalizedHotkeyString; | ||
export declare function eventToHotkeyString(event: KeyboardEvent, platform?: string): NormalizedHotkeyString; | ||
export declare function normalizeHotkey(hotkey: string, platform?: string | undefined): NormalizedHotkeyString; | ||
export {}; |
@@ -0,3 +1,5 @@ | ||
import { macosSymbolLayerKeys } from './macos-symbol-layer'; | ||
const normalizedHotkeyBrand = Symbol('normalizedHotkey'); | ||
export function eventToHotkeyString(event) { | ||
export function eventToHotkeyString(event, platform = navigator.platform) { | ||
var _a; | ||
const { ctrlKey, altKey, metaKey, key } = event; | ||
@@ -11,3 +13,4 @@ const hotkeyString = []; | ||
if (!modifierKeyNames.includes(key)) { | ||
hotkeyString.push(key); | ||
const nonOptionPlaneKey = matchApplePlatform.test(platform) ? (_a = macosSymbolLayerKeys[key]) !== null && _a !== void 0 ? _a : key : key; | ||
hotkeyString.push(nonOptionPlaneKey); | ||
} | ||
@@ -14,0 +17,0 @@ return hotkeyString.join('+'); |
@@ -73,3 +73,96 @@ class Leaf { | ||
function eventToHotkeyString(event) { | ||
const macosSymbolLayerKeys = { | ||
['¡']: '1', | ||
['™']: '2', | ||
['£']: '3', | ||
['¢']: '4', | ||
['∞']: '5', | ||
['§']: '6', | ||
['¶']: '7', | ||
['•']: '8', | ||
['ª']: '9', | ||
['º']: '0', | ||
['–']: '-', | ||
['≠']: '=', | ||
['`']: '~', | ||
['⁄']: '!', | ||
['€']: '@', | ||
['‹']: '#', | ||
['›']: '$', | ||
['fi']: '%', | ||
['fl']: '^', | ||
['‡']: '&', | ||
['°']: '*', | ||
['·']: '(', | ||
['‚']: ')', | ||
['—']: '_', | ||
['±']: '+', | ||
['œ']: 'q', | ||
['∑']: 'w', | ||
['®']: 'r', | ||
['†']: 't', | ||
['¥']: 'y', | ||
['ø']: 'o', | ||
['π']: 'p', | ||
['“']: '[', | ||
['‘']: ']', | ||
['«']: '\\', | ||
['Œ']: 'Q', | ||
['„']: 'W', | ||
['´']: 'E', | ||
['‰']: 'R', | ||
['ˇ']: 'T', | ||
['Á']: 'Y', | ||
['¨']: 'U', | ||
['ˆ']: 'I', | ||
['Ø']: 'O', | ||
['∏']: 'P', | ||
['”']: '{', | ||
['’']: '}', | ||
['»']: '|', | ||
['å']: 'a', | ||
['ß']: 's', | ||
['∂']: 'd', | ||
['ƒ']: 'f', | ||
['©']: 'g', | ||
['˙']: 'h', | ||
['∆']: 'j', | ||
['˚']: 'k', | ||
['¬']: 'l', | ||
['…']: ';', | ||
['æ']: "'", | ||
['Å']: 'A', | ||
['Í']: 'S', | ||
['Î']: 'D', | ||
['Ï']: 'F', | ||
['˝']: 'G', | ||
['Ó']: 'H', | ||
['Ô']: 'J', | ||
['']: 'K', | ||
['Ò']: 'L', | ||
['Ú']: ':', | ||
['Æ']: '"', | ||
['Ω']: 'z', | ||
['≈']: 'x', | ||
['ç']: 'c', | ||
['√']: 'v', | ||
['∫']: 'b', | ||
['µ']: 'm', | ||
['≤']: ',', | ||
['≥']: '.', | ||
['÷']: '/', | ||
['¸']: 'Z', | ||
['˛']: 'X', | ||
['Ç']: 'C', | ||
['◊']: 'V', | ||
['ı']: 'B', | ||
['˜']: 'N', | ||
['Â']: 'M', | ||
['¯']: '<', | ||
['˘']: '>', | ||
['¿']: '?' | ||
}; | ||
function eventToHotkeyString(event, platform = navigator.platform) { | ||
var _a; | ||
const { ctrlKey, altKey, metaKey, key } = event; | ||
@@ -83,3 +176,4 @@ const hotkeyString = []; | ||
if (!modifierKeyNames.includes(key)) { | ||
hotkeyString.push(key); | ||
const nonOptionPlaneKey = matchApplePlatform.test(platform) ? (_a = macosSymbolLayerKeys[key]) !== null && _a !== void 0 ? _a : key : key; | ||
hotkeyString.push(nonOptionPlaneKey); | ||
} | ||
@@ -86,0 +180,0 @@ return hotkeyString.join('+'); |
{ | ||
"name": "@github/hotkey", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -88,3 +88,3 @@ # Hotkey Behavior | ||
install(el, el.dataset.shortcut) | ||
if (el.matches('.frobber')) { | ||
@@ -94,4 +94,4 @@ el.addEventListener('hotkey-fire', event => { | ||
event.preventDefault() | ||
// Use a custom behaviour instead | ||
// Use a custom behaviour instead | ||
frobulateFrobber(event.target) | ||
@@ -122,5 +122,6 @@ }) | ||
'a b,Control+Alt+/' | ||
``` | ||
🔬 **Hotkey Mapper** is a tool to help you determine the correct hotkey string for your key combination: https://github.github.io/hotkey/examples/hotkey_mapper.html | ||
🔬 **Hotkey Mapper** is a tool to help you determine the correct hotkey string for your key combination: <https://github.github.io/hotkey/pages/hotkey_mapper.html> | ||
@@ -127,0 +128,0 @@ #### Key-sequence considerations |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30065
15
732
169