deck.js
deck.js copied to clipboard
Review key handling (avoid e.which and allow modifiers)
-
event.which
is deprecated - it could be convenient to provide a simple way to accept modifiers,
e.g., currently:
- 65 means key 'a'
- [65, 66] means keys 'a' or 'b' but we could imagine accepting something emacs-inspired like
- ["C-S-65", 66] for control+shift+'a', or 'b'
At the moment, using the short to copy "Cmd/Ctrl + C" runs unintentionally the clone plugin. Does this proposal would avoid the aforementioned issue?
Not originally, but if this gets implemented, it would probably make sense to consider Cmd and Ctrl as the same modifier (at least by default).
Did you encounter the issue with Cmd only or also with Ctrl? The Ctrl case should already be handled by the clone extension https://github.com/twitwi/deck.js/blob/master/extensions/clone/deck.clone.js#L186 Let me know and I'll fix the Cmd key in the clone extension (I guess Cmd+C is most used).
Here are some links for any possible future work on this feature:
- ev.metaKey for Cmd https://stackoverflow.com/a/5500536/2297277
- libraries for simplified key handling https://github.com/madrobby/keymaster/issues/139 (consider keymaster itself + the list in the issue)
I forgot to mention I am using macOS (where the copy shortcut uses the Cmd modifier). Indeed, you are right, "Ctrl + C" is OK. Doing the same fix for the Cmd modifier would be very great. Thank you.
I pushed a tentative fix (untested but I might have typed it right :) ).
I've just tested it, it works perfectly. Thank you.
Great. Thanks for the feedback.