atom / atom-keymap

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

Idea: Replace hand-rolled selector matching with CSS Custom Properties #119

Open nathansobo opened 8 years ago

nathansobo commented 8 years ago

We could bind keystrokes to commands via CSS custom properties associated with selectors. We currently do this anyway on a conceptual level but are forced to match selectors manually. Using custom properties might make it faster to match bindings and would probably make troubleshooting bindings much easier due to dev-tools support.

If anyone that's seriously interested in trying this please let me know and I can provide guidance. This relies on upgrading Atom to Electron 0.37.0 which is incomplete at the time of this writing, but will certainly happen. You can test this library in isolation to experiment with the idea.

Example:

body {
  --atom-binding--ctrl-x_ctrl-s: 'core:save'
}

Then in JS we could just read the computed style when dispatching keyboard events instead of matching selectors.