2 * Keys to ignore when recording shortcuts.
5 const ignoreKeys = ['Control', 'Alt', 'Shift', 'Meta', 'Super', ' ', '+', 'Tab', 'Escape'];
13 this.input = this.$el;
15 this.setupListeners();
19 this.listenerRecordKey = this.listenerRecordKey.bind(this);
21 this.input.addEventListener('focus', () => {
22 this.startListeningForInput();
25 this.input.addEventListener('blur', () => {
26 this.stopListeningForInput();
30 startListeningForInput() {
31 this.input.addEventListener('keydown', this.listenerRecordKey)
35 * @param {KeyboardEvent} event
37 listenerRecordKey(event) {
38 if (ignoreKeys.includes(event.key)) {
43 event.ctrlKey ? 'Ctrl' : '',
44 event.metaKey ? 'Cmd' : '',
48 this.input.value = keys.filter(s => Boolean(s)).join(' + ');
51 stopListeningForInput() {
52 this.input.removeEventListener('keydown', this.listenerRecordKey);
57 export default ShortcutInput;