Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
component.js
component.json
dependencies.html
example.html
picture.jpg
readme.md

readme.md

j-Shortcuts

This component can help with creating keyboard shortcuts. The component is singleton.

Methods:

  • component.register(shortcut, callback(e), [prevent]) - registers a new shortcut
  • component.exec('shortcut') - evaluates shortcut

Shortcuts:

  • enter
  • esc
  • tab
  • cmd, meta, win
  • shift, capslock
  • ctrl
  • alt
  • space
  • backspace, del, delete
  • left, up, right, down
  • F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12
  • or custom key-codes {Number} or key-characters {String(1)}
  • NEW: ins

Example:

// SETTER(true, ...) --> works in jComponent +v9.0.0

SETTER(true, 'shortcuts', 'register', 'cmd + enter', function(e) {
    console.log('PRESSED: CMD + ENTER');
});

SETTER(true, 'shortcuts', 'register', 'alt + p', function(e) {
    console.log('PRESSED: ALT + P');
});

SETTER(true, 'shortcuts', 'register', 'esc', function(e) {
    console.log('PRESSED: esc');
});

// +v3 supports multiple shortcuts at the one time:
SETTER(true, 'shortcuts', 'register', 'cmd+enter, ctrl+enter', function(e) {
    console.log('PRESSED: CMD + ENTER');
});

Author

You can’t perform that action at this time.