How to use atom-keymap - 4 common examples

To help you get started, we’ve selected a few atom-keymap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / nteract / src / notebook / keys / keymap.js View on Github external
export function initKeymap(window, dispatch) {
  registerListeners(window, dispatch);

  const document = window.document;
  const keymaps = new KeymapManager();
  keymaps.defaultTarget = document.body;
  document.addEventListener('keydown', event => keymaps.handleKeyboardEvent(event));

  // Add the keymap files, can also be specified as directories
  keymaps.add('/default-keymap', require('../../../static/default-map.json'));
  // keymaps.loadKeymap('/path/to/keymap-file.json');
}
github DefinitelyTyped / DefinitelyTyped / types / atom-keymap / atom-keymap-tests.ts View on Github external
import { KeymapManager, ICompleteMatchEvent } from "atom-keymap";

var manager = new KeymapManager();
manager.add('some/unique/path', {
    '.workspace': {
        'ctrl-x': 'package:do-something',
        'ctrl-y': 'package:do-something-else'
    },
    '.mini.editor': {
        'enter': 'core:confirm'
    }
});

manager.onDidMatchBinding((event: ICompleteMatchEvent): void => {
    console.log(event.binding.command);
})

manager.destroy();
github atom / atom / spec / window-event-handler-spec.js View on Github external
it('dispatches the event via the KeymapManager and CommandRegistry', () => {
      const dispatchedCommands = [];
      atom.commands.onWillDispatch(command => dispatchedCommands.push(command));
      atom.commands.add('*', { 'foo-command': () => {} });
      atom.keymaps.add('source-name', { '*': { x: 'foo-command' } });

      const event = KeymapManager.buildKeydownEvent('x', {
        target: document.createElement('div')
      });
      document.dispatchEvent(event);

      expect(dispatchedCommands.length).toBe(1);
      expect(dispatchedCommands[0].type).toBe('foo-command');
    }));
github picturama / picturama / src / ui / keymap-manager.js View on Github external
const bind = el => {
  keymaps = new KeymapManager();
  keymaps.defaultTarget = el;
  keymaps.loadKeymap(`${config.keymapsFolder}/linux.json`);

  document.addEventListener('keydown', eventListener);
};

atom-keymap

Atom's DOM-aware keymap module

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages