Skip to content

Commit

Permalink
fix(keyboard): add brackets to defaultKeyMap (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
bawjensen authored Jan 21, 2025
1 parent f0468d0 commit 543ecb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/keyboard/keyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DOM_KEY_LOCATION, keyboardKey} from '../system/keyboard'
* Mapping for a default US-104-QWERTY keyboard
*/
export const defaultKeyMap: keyboardKey[] = [
// alphanumeric keys
// alphanumeric block - writing system
...'0123456789'.split('').map(c => ({code: `Digit${c}`, key: c})),
...')!@#$%^&*('
.split('')
Expand All @@ -16,6 +16,11 @@ export const defaultKeyMap: keyboardKey[] = [
.split('')
.map(c => ({code: `Key${c}`, key: c, shiftKey: true})),

{code: 'BracketLeft', key: '['},
{code: 'BracketLeft', key: '{', shiftKey: true},
{code: 'BracketRight', key: ']'},
{code: 'BracketRight', key: '}', shiftKey: true},

// alphanumeric block - functional
{code: 'Space', key: ' '},

Expand Down
8 changes: 4 additions & 4 deletions tests/keyboard/parseKeyDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ 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/}',
keyDef: {key: '/', code: 'Unknown'},
},
'[ as printable': {
text: '[[',
keyDef: {key: '[', code: 'Unknown'},
keyDef: {key: '[', code: 'BracketLeft'},
},
},
)
Expand Down

0 comments on commit 543ecb0

Please sign in to comment.