Atom keymap
Atom's DOM-aware keymap module
var KeymapManager, keymaps;
KeymapManager = require('atom-keymap')
keymaps = new KeymapManager
keymaps.defaultTarget = document.body
document.addEventListener('keydown', function(event) {
keymaps.handleKeyboardEvent(event)
})
keymaps.loadKeymap('/path/to/keymap-file.json')
keymaps.add('/key/for/these/keymaps', {
"body": {
"up": "core:move-up",
"down": "core:move-down"
}
})
window.addEventListener('core:move-up', (event) => console.log('up', event))
window.addEventListener('core:move-down', (event) => console.log('down', event))
Development
The tests for this module must be run in Electron because they depend on browser APIs.
devtool
is bundled as a development dependency to run the tests.- Native modules need to be compiled against the version of Electron included with
devtool
. Be sure to run electron-rebuild
be sure recompile native dependencies before running tests. - Tests can be run in batch mode with
npm test
- If you want to use the debugger, profiler, etc or just speed up your flow by being able to refresh the
devtool
window to re-run tests, use the npm run test-drive
script. This will keep devtool
open instead of exiting after the test run.