Normalize keystrokes to use shift and the uppercase letter

`cmd-shift-l`, `cmd-L` and `cmd-shift-L` all normalize to `cmd-shift-L`
This commit is contained in:
probablycorey
2014-03-04 17:36:03 -08:00
parent 8b673c7adf
commit d0889cca31
3 changed files with 17 additions and 7 deletions

View File

@@ -270,6 +270,14 @@ describe "Keymap", ->
expect(result).toBe(false)
expect(fooHandler).toHaveBeenCalled()
it "normalizes bindings that use an upper case alpha char without shift", ->
fooHandler = jasmine.createSpy('fooHandler')
fragment.on 'foo', fooHandler
keymap.bindKeys 'name', '*', 'ctrl-L': 'foo'
result = keymap.handleKeyEvent(keydownEvent('l', ctrlKey: true, altKey: false, shiftKey: true, target: fragment[0]))
expect(result).toBe(false)
expect(fooHandler).toHaveBeenCalled()
it "normalizes the key patterns in the hash to put the modifiers in alphabetical order", ->
fooHandler = jasmine.createSpy('fooHandler')
fragment.on 'foo', fooHandler
@@ -322,7 +330,7 @@ describe "Keymap", ->
describe "when shift is pressed when a non-modifer key", ->
it "returns a string that identifies the key pressed", ->
expect(keymap.keystrokeStringForEvent(keydownEvent('A', shiftKey: true))).toBe 'A'
expect(keymap.keystrokeStringForEvent(keydownEvent('A', shiftKey: true))).toBe 'shift-A'
expect(keymap.keystrokeStringForEvent(keydownEvent('{', shiftKey: true))).toBe '{'
expect(keymap.keystrokeStringForEvent(keydownEvent('left', shiftKey: true))).toBe 'shift-left'
expect(keymap.keystrokeStringForEvent(keydownEvent('Left', shiftKey: true))).toBe 'shift-left'