Closed jenstornell closed 3 years ago
Oh, now that I know that it's a bug and not intended behaviour, here's something I've noticed: It seems to happen only when no form element (a textbox, textarea, select, etc) is selected.
@rasteiner It also only happends when the "template switcher" is available.
It's interesting to know that the "keyCode" for F5 is 116, but "charCode 116" in ascii is "t" (lowercase T). Don't know if there was meant to be a short cut with "t" for the template changer.
See here what happens when I press F5:
(event.which
and event.keyCode
are both 116)
Thank you very much for the details, @rasteiner! After quite some time of tracking this down I found out that this is a bug in the jQuery hotkeys plugin:
t
as you suspected (this is done via a data-shortcut
attribute on the link)String.fromCharCode( event.which ).toLowerCase()
so it uses the ASCII value instead of the key code.F5
matches for t
even though it shouldn't have.We can't fix this directly in Kirby, but we will need to look for a new hotkey library. @bastianallgeier?
Do you really need a library for that? I did not need it in Splitview.
https://github.com/jenstornell/splitview/blob/master/assets/js/src/site/site.js#L51
I did not say "framework", just "library". :) A library for this is useful because it knows about special key codes like the F keys, backspace, escape etc.
BTW: Your code seems to have the same problem with the ASCII key codes. ;)
I'll leave a few suggestions for possible alternatives to the hotkeys plugin. Since I know @bastianallgeier loves to be a "purist" of the web (and so do I) the following are pure js libraries, no jQuery involved.
Not sure if these are 100% what you guys are looking for but maybe I'll save you a few searches.
any progress on this one?
Sorry for the delay! We haven't been able to fix this in Kirby 2, but as far as I can tell, Kirby 3 (which will be out soon) won't have this issue. :)
More here:
https://forum.getkirby.com/t/changing-templates-in-panel-super-nice-but/4281