'prevent' blocks all default browser hotkeys
marcopennekamp opened this issue · 2 comments
As it currently stands, attaching .prevent
to v-hotkey
blocks all default browser hotkeys, not just the ones specified in the keymap.
I don't think this is desired behavior in the vast majority of use cases. The standard use case would be to "overwrite" browser hotkeys with your own hotkeys while leaving the other mappings alone. For example, in my case, I need to overwrite the "save" hotkey, thus overwriting CTRL+S and META+S. However, using .prevent
also blocks CMD+H (hide window on Mac) and CMD+R (reload the page), for example.
I've checked out the code and I think this can be easily achieved by only calling e.preventDefault
when, inside the for loop of bindEvent
, the code has found a hotkey match for the callback. This would only prevent the default behavior if the key has been recognised by v-hotkey.
I agree, PR is welcome
A workaround is instead of using v-hotkey.prevent
, use event.preventDefault()
in the shortcut handlers.