Skip to content

Commit 764653e

Browse files
committed
Fix scenarios where key is undefined
1 parent 39a016b commit 764653e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/app/src/app/store/providers/KeybindingManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function handleKeyDown(controller, e) {
3131

3232
const key = normalizeKey(e);
3333

34+
if (!key) {
35+
return;
36+
}
37+
3438
// First we check if we have any pending secondary bindings to identify
3539
if (state.pendingSecondaryBindings.length) {
3640
// We filter out any hits by verifying that the current key matches the next

packages/common/utils/keybindings.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ const metaKey = isMac ? 'Meta' : 'Alt';
55
const metaOrCtrlKey = isMac ? 'Meta' : 'Control';
66

77
export function normalizeKey(e: KeyboardEvent) {
8-
if (e.key.split('').length === 1) {
9-
const key = String.fromCharCode(e.keyCode).toUpperCase();
10-
if (key === ' ') {
11-
return 'Space';
8+
if (e.key) {
9+
if (e.key.split('').length === 1) {
10+
const key = String.fromCharCode(e.keyCode).toUpperCase();
11+
if (key === ' ') {
12+
return 'Space';
13+
}
14+
return key;
1215
}
13-
return key;
16+
17+
return e.key;
1418
}
1519

16-
return e.key;
20+
return undefined;
1721
}
1822

1923
export function formatKey(key: string) {

0 commit comments

Comments
 (0)