@github/hotkey
Advanced tools
Comparing version 2.2.0 to 2.3.0
import { macosSymbolLayerKeys } from './macos-symbol-layer'; | ||
const normalizedHotkeyBrand = Symbol('normalizedHotkey'); | ||
const syntheticKeyNames = { | ||
' ': 'Space', | ||
'+': 'Plus' | ||
}; | ||
export function eventToHotkeyString(event, platform = navigator.platform) { | ||
var _a; | ||
var _a, _b; | ||
const { ctrlKey, altKey, metaKey, key } = event; | ||
@@ -14,3 +18,4 @@ const hotkeyString = []; | ||
const nonOptionPlaneKey = matchApplePlatform.test(platform) ? (_a = macosSymbolLayerKeys[key]) !== null && _a !== void 0 ? _a : key : key; | ||
hotkeyString.push(nonOptionPlaneKey); | ||
const syntheticKey = (_b = syntheticKeyNames[nonOptionPlaneKey]) !== null && _b !== void 0 ? _b : nonOptionPlaneKey; | ||
hotkeyString.push(syntheticKey); | ||
} | ||
@@ -17,0 +22,0 @@ return hotkeyString.join('+'); |
@@ -165,4 +165,8 @@ class Leaf { | ||
const syntheticKeyNames = { | ||
' ': 'Space', | ||
'+': 'Plus' | ||
}; | ||
function eventToHotkeyString(event, platform = navigator.platform) { | ||
var _a; | ||
var _a, _b; | ||
const { ctrlKey, altKey, metaKey, key } = event; | ||
@@ -177,3 +181,4 @@ const hotkeyString = []; | ||
const nonOptionPlaneKey = matchApplePlatform.test(platform) ? (_a = macosSymbolLayerKeys[key]) !== null && _a !== void 0 ? _a : key : key; | ||
hotkeyString.push(nonOptionPlaneKey); | ||
const syntheticKey = (_b = syntheticKeyNames[nonOptionPlaneKey]) !== null && _b !== void 0 ? _b : nonOptionPlaneKey; | ||
hotkeyString.push(syntheticKey); | ||
} | ||
@@ -180,0 +185,0 @@ return hotkeyString.join('+'); |
{ | ||
"name": "@github/hotkey", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -112,3 +112,4 @@ # Hotkey Behavior | ||
3. Due to the inconsistent lowercasing of `event.key` on Mac and iOS when `Meta` is pressed along with `Shift`, it is recommended to avoid hotkey strings containing both `Mod` and `Shift`. | ||
7. You can use the comma key `,` as a hotkey, e.g. `a,,` would activate if the user typed `a` or `,`. `Control+,,x` would activate for `Control+,` or `x`. | ||
7. `"Plus"` and `"Space"` are special key names to represent the `+` and ` ` keys respectively, because these symbols cannot be represented in the normal hotkey string syntax. | ||
8. You can use the comma key `,` as a hotkey, e.g. `a,,` would activate if the user typed `a` or `,`. `Control+,,x` would activate for `Control+,` or `x`. | ||
@@ -115,0 +116,0 @@ ### Example |
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
30619
742
170