deck.js icon indicating copy to clipboard operation
deck.js copied to clipboard

Review key handling (avoid e.which and allow modifiers)

Open twitwi opened this issue 7 years ago • 7 comments

  • 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'

twitwi avatar Aug 23 '17 19:08 twitwi

At the moment, using the short to copy "Cmd/Ctrl + C" runs unintentionally the clone plugin. Does this proposal would avoid the aforementioned issue?

vins31 avatar Apr 14 '18 17:04 vins31

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).

twitwi avatar Apr 14 '18 18:04 twitwi

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)

twitwi avatar Apr 14 '18 18:04 twitwi

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.

vins31 avatar Apr 14 '18 19:04 vins31

I pushed a tentative fix (untested but I might have typed it right :) ).

twitwi avatar Apr 17 '18 09:04 twitwi

I've just tested it, it works perfectly. Thank you.

vins31 avatar Apr 17 '18 11:04 vins31

Great. Thanks for the feedback.

twitwi avatar Apr 17 '18 11:04 twitwi