Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement
Atom's DOM-aware keymap module
varKeymapManager,keymaps;KeymapManager=require('atom-keymap')keymaps=newKeymapManagerkeymaps.defaultTarget=document.body// Pass all the window's keydown events to the KeymapManagerdocument.addEventListener('keydown',function(event){keymaps.handleKeyboardEvent(event)})// Add some keymapskeymaps.loadKeymap('/path/to/keymap-file.json')// can also be a directory of json / cson files// ORkeymaps.add('/key/for/these/keymaps',{"body": {"up": "core:move-up","down": "core:move-down"}})// When a keybinding is triggered, it will dispatch it on the node that was focusedwindow.addEventListener('core:move-up',(event)=>console.log('up',event))window.addEventListener('core:move-down',(event)=>console.log('down',event))The tests for this module must be run in Electron because they depend on browser APIs.
devtoolis 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 runelectron-rebuildbe 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
devtoolwindow to re-run tests, use thenpm run test-drivescript. This will keepdevtoolopen instead of exiting after the test run.