atom / atom-keymap

Atom's selector-based keymap system
MIT License
105 stars 58 forks source link

Add public custom keystroke resolver API #164

Closed nathansobo closed 8 years ago

nathansobo commented 8 years ago

@atom/maintainers I thought I'd make you aware of this API since it may be useful to suggest to users experiencing weird edge cases with keystroke resolution. I plan to hotfix it to 1.12-releases to ensure there's a fallback strategy for any remaining keyboard layout issues we may have missed with the internationalization improvements.

Rationale

There are quite a few Chrome bugs related to keyboard events on Linux. In addition, user expectations sometimes differ from our default behavior with respect to how we should interpret modifier keys on international keyboards. Finally, there are special modifier keys and crazy layouts on Linux that we don't have time to support right now.

Keystroke resolvers

The solution to all these problems and more is to allow users or packages to insert custom logic for resolving certain keyboard events to keystroke strings. When this PR lands, you'll be able to do something like the following.

atom.keymaps.addKeystrokeResolver(({event}) => {
  if (event.code === 'KeyG' && event.altKey && event.ctrlKey) {
    return 'ctrl-@'
  }
})

See the API documentation for more details.