shortcutter
Version:
Tiny, dependency-free library to manage keyboard shortcuts in your application.
13 lines (12 loc) • 427 B
JavaScript
import { PHASES_SEPARATOR } from './types';
export function normalizeKeyCode(code) {
return code.toLowerCase().replace(/key/, '');
}
export function normalizeShortcut(keys) {
return keys.sort().join('+').toLowerCase();
}
export function phasesIterator(phases, shortcut, callback) {
phases.split(PHASES_SEPARATOR).forEach(function (phase) {
callback("".concat(shortcut, "_").concat(phase), phase);
});
}