Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #154 from atom/ns-fix-ctrl-backspace-with-numlock
Browse files Browse the repository at this point in the history
Fix incorrect interpretation of ctrl-backspace when numlock is enabled on Windows
  • Loading branch information
Nathan Sobo authored Oct 15, 2016
2 parents c7c9ff2 + b54bb8c commit eaa98ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion spec/keymap-manager-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,14 @@ describe "KeymapManager", ->
assert.equal(keymapManager.keystrokeForKeyboardEvent(buildKeydownEvent({key: '{', shiftKey: true})), '{')

describe "when the KeyboardEvent.key is a capital letter due to caps lock, but shift is not pressed", ->
it.only "converts the letter to lower case", ->
it "converts the letter to lower case", ->
assert.equal(keymapManager.keystrokeForKeyboardEvent(buildKeydownEvent({key: 'A', shiftKey: false})), 'a')
assert.equal(keymapManager.keystrokeForKeyboardEvent(buildKeydownEvent({key: 'A', shiftKey: false, altKey: true})), 'alt-a')

describe "when the KeyboardEvent.key is 'Delete' but KeyboardEvent.code is 'Backspace' due to pressing ctrl-delete with numlock enabled on Windows", ->
it "translates as ctrl-backspace instead of ctrl-delete", ->
assert.equal(keymapManager.keystrokeForKeyboardEvent(buildKeydownEvent({key: 'Delete', code: 'Backspace', ctrlKey: true})), 'ctrl-backspace')

describe "when the Dvorak QWERTY-⌘ layout is in use on macOS", ->
it "uses the US layout equivalent when the command key is held down", ->
mockProcessPlatform('darwin')
Expand Down
3 changes: 2 additions & 1 deletion src/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ MODIFIERS = new Set(['ctrl', 'alt', 'shift', 'cmd'])
ENDS_IN_MODIFIER_REGEX = /(ctrl|alt|shift|cmd)$/
WHITESPACE_REGEX = /\s+/
KEY_NAMES_BY_KEYBOARD_EVENT_CODE = {
'Space': 'space'
'Space': 'space',
'Backspace': 'backspace'
}
NON_CHARACTER_KEY_NAMES_BY_KEYBOARD_EVENT_KEY = {
'Control': 'ctrl',
Expand Down

0 comments on commit eaa98ad

Please sign in to comment.