From e521f50628d541d939057b9a6099a75e54fb4b44 Mon Sep 17 00:00:00 2001 From: Bryan Jensen Date: Tue, 18 Jun 2024 12:43:07 -0700 Subject: [PATCH] fix(keyboard): add brackets (`[]{}`) to defaultKeyMap for keyboard()/type() --- src/keyboard/keyMap.ts | 4 ++++ tests/keyboard/parseKeyDef.ts | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/keyboard/keyMap.ts b/src/keyboard/keyMap.ts index 51afcd2f..47465064 100644 --- a/src/keyboard/keyMap.ts +++ b/src/keyboard/keyMap.ts @@ -18,6 +18,10 @@ export const defaultKeyMap: keyboardKey[] = [ // alphanumeric block - functional {code: 'Space', key: ' '}, + {code: 'BracketLeft', key: '['}, + {code: 'BracketRight', key: ']'}, + {code: 'BracketLeft', key: '{', shiftKey: true}, + {code: 'BracketRight', key: '}', shiftKey: true}, {code: 'AltLeft', key: 'Alt', location: DOM_KEY_LOCATION.LEFT}, {code: 'AltRight', key: 'Alt', location: DOM_KEY_LOCATION.RIGHT}, diff --git a/tests/keyboard/parseKeyDef.ts b/tests/keyboard/parseKeyDef.ts index 1dd6b7d8..e5018742 100644 --- a/tests/keyboard/parseKeyDef.ts +++ b/tests/keyboard/parseKeyDef.ts @@ -44,18 +44,18 @@ cases( }, '{ as printable': { text: '{{', - keyDef: {key: '{', code: 'Unknown'}, + keyDef: {key: '{', code: 'BracketLeft', shiftKey: true}, }, '{ as printable followed by descriptor': { text: '{{{foo}', keyDef: [ - {key: '{', code: 'Unknown'}, + {key: '{', code: 'BracketLeft', shiftKey: true}, {key: 'foo', code: 'Unknown'}, ], }, '{ as key with modifiers': { text: '{\\{>5/}', - keyDef: {key: '{', code: 'Unknown'}, + keyDef: {key: '{', code: 'BracketLeft', shiftKey: true}, }, 'modifier as key with modifiers': { text: '{/\\/>5/}', @@ -63,7 +63,7 @@ cases( }, '[ as printable': { text: '[[', - keyDef: {key: '[', code: 'Unknown'}, + keyDef: {key: '[', code: 'BracketLeft'}, }, }, )