mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 09:01:33 +03:00
Handle modifier keydown events
When only a modifier is pressed it still triggers a keydown event. This normalizes the keystroke name for those events.
This commit is contained in:
parent
94b5d08b63
commit
9e8b1fb661
@ -6,6 +6,8 @@ CSON = require 'season'
|
|||||||
BindingSet = require './binding-set'
|
BindingSet = require './binding-set'
|
||||||
{Emitter} = require 'emissary'
|
{Emitter} = require 'emissary'
|
||||||
|
|
||||||
|
Modifiers = ['alt', 'control', 'ctrl', 'shift', 'meta']
|
||||||
|
|
||||||
# Internal: Associates keymaps with actions.
|
# Internal: Associates keymaps with actions.
|
||||||
#
|
#
|
||||||
# Keymaps are defined in a CSON format. A typical keymap looks something like this:
|
# Keymaps are defined in a CSON format. A typical keymap looks something like this:
|
||||||
@ -189,14 +191,14 @@ class Keymap
|
|||||||
key = event.originalEvent.keyIdentifier.toLowerCase()
|
key = event.originalEvent.keyIdentifier.toLowerCase()
|
||||||
|
|
||||||
modifiers = []
|
modifiers = []
|
||||||
if event.altKey and key isnt 'alt'
|
if event.altKey and key not in Modifiers
|
||||||
modifiers.push 'alt'
|
modifiers.push 'alt'
|
||||||
if event.ctrlKey and key isnt 'ctrl'
|
if event.ctrlKey and key not in Modifiers
|
||||||
modifiers.push 'ctrl'
|
modifiers.push 'ctrl'
|
||||||
if event.metaKey and key isnt 'meta'
|
if event.metaKey and key not in Modifiers
|
||||||
modifiers.push 'meta'
|
modifiers.push 'meta'
|
||||||
|
|
||||||
if event.shiftKey
|
if event.shiftKey and key not in Modifiers
|
||||||
isNamedKey = key.length > 1
|
isNamedKey = key.length > 1
|
||||||
modifiers.push 'shift' if isNamedKey
|
modifiers.push 'shift' if isNamedKey
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user