Skip to content

Commit

Permalink
fix: #139 cannot use numpad keyboard to enter numbers in tree mode
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 12, 2022
1 parent 28b2b56 commit e2383d9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@
// get key combo, and normalize key combo from Mac: replace "Command+X" with "Ctrl+X" etc
const combo = keyComboFromEvent(event).replace(/^Command\+/, 'Ctrl+')
const keepAnchorPath = event.shiftKey
debug('keydown', { combo, key: event.key })
if (combo === 'Ctrl+X') {
// cut formatted
Expand Down Expand Up @@ -1889,11 +1890,14 @@
}
}
if (combo.length === (combo.startsWith('Shift+') ? 7 : 1) && documentState.selection) {
const normalizedCombo = combo
.replace(/^Shift\+/, '') // replace 'Shift+A' with 'A'
.replace(/^Numpad_/, '') // replace 'Numpad_4' with '4'
if (normalizedCombo.length === 1 && documentState.selection) {
// a regular key like a, A, _, etc is entered.
// Replace selected contents with a new value having this first character as text
event.preventDefault()
handleInsertCharacter(event.key)
handleInsertCharacter(normalizedCombo)
return
}
Expand Down

0 comments on commit e2383d9

Please sign in to comment.