hotkeys-js
hotkeys-js copied to clipboard
How to prevent hotkey to trigger event again and again if key is pressed?
Hi,
import hotkeys from 'hotkeys-js';
hotkeys('ctrl+s', function (e) { alert('do something', e); });
If I keep holding ctrl+s, this event keep getting fired, Is there a way to stop that?
@ervishal89 Upgrade [email protected]
.
key down and key up both perform callback events.
hotkeys('ctrl+a,alt+a+s', { keyup: true }, (evn, handler) => {
if(evn.type === 'keydown') {
console.log('keydown:', evn.type, handler, handler.key);
}
if(evn.type === 'keyup') {
console.log('keyup:', evn.type, handler, handler.key);
}
});
Use e.repeat
That will be true on repeat firings of the event