Ignore keyup events for modifier keys
This commit is contained in:
parent
03d164c9d3
commit
a7df7adc8e
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
const id = Math.random().toString().slice(2);
|
const id = Math.random().toString().slice(2);
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
const modifierKeys = new Set(['Alt', 'AltGraph', 'Control', 'Fn', 'FnLock', 'Meta', 'Shift', 'Super', ]);
|
||||||
let listening = false;
|
let listening = false;
|
||||||
|
|
||||||
function listen() {
|
function listen() {
|
||||||
@ -20,12 +21,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setKeybind(event) {
|
function setKeybind(event) {
|
||||||
console.log(event);
|
// separate events fire for modifier keys, even when they are combined with a regular key
|
||||||
|
if (modifierKeys.has(event.key)) return;
|
||||||
|
|
||||||
let keys = [];
|
let keys = [];
|
||||||
if (event.ctrlKey) keys.push('ctrl');
|
if (event.ctrlKey) keys.push('Ctrl');
|
||||||
if (event.altKey) keys.push('alt');
|
if (event.altKey) keys.push('Alt');
|
||||||
if (event.metaKey) keys.push('meta');
|
if (event.metaKey) keys.push('Meta');
|
||||||
if (event.shiftKey) keys.push('shift');
|
if (event.shiftKey) keys.push('Shift');
|
||||||
|
// capitalize
|
||||||
keys.push(event.key);
|
keys.push(event.key);
|
||||||
|
|
||||||
value.keys = keys.join('+');
|
value.keys = keys.join('+');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user