damianavila / RISE

RISE: "Live" Reveal.js Jupyter/IPython Slideshow Extension
Other
3.68k stars 417 forks source link

custom chalkboard key config added (main.js + rise.yaml) #525

Closed theck3r closed 4 years ago

theck3r commented 4 years ago

Hi, I have added some code to customize the keyboard short cuts for the chalkboard (as most of the hard wired default keys are not available on my german keyboard).

I guess this is not the perfect solution (read the discussion in #442), but it allows using some custom hotkey fields in nbconfig and converts the key-strings into key codes, which are then passed to the RevealChalkboard setup (could be used for other reveal.js keys as well, I guess...).

Conversion is done by a pretty simple string concatenation of the nbconfig key-shortcut string(s) to KeyEvent's VirtualKeyboardConstants (DOMVK...) - falls back to the default key codes, if no match is found. I also added some code for updating the Rise help accordingly - so the help menu should always show the user defined shortcuts (if they could be converted).

Seems to work well on my system - linux/firefox (although some DOMVK... constants are missing), but I am rather new to javascript, so any feedback is welcome.

regards, Thies

parmentelat commented 4 years ago

Hi

That sounds pretty exciting, and I've wished I had a way to customize hard-wired shortcuts for a long time now; and I can see you've spotted the original discussion on that matter

I had other ideas about how to deal with that, but that's going to be for some other time - if ever, actually..

so on the principle I'm fine; I'm not sure when I will have a chance to release this; our plans were to focus on the jlab thing, but that has gotten a little stuck in the meantime, so I guess the classic notebook extension still has some future; I guess it would belong in a 5.6.1.dev

if it's not too much hassle, I'd love if you could extend this patch to cover the home and end functions as well among the parametrizable features ? also, do you see any impact on the documentation as shown at rise.readthedocs.io ?

thanks !

theck3r commented 4 years ago

I have just pushed some updates including the extension for the home and end keys you asked for. Actually I tried to cover all bindings that were directly assigning keycodes to reveal.js API calls or RISE functions (so I have included e.g. toggleOverview, toggleAllRiseButtons,...).

To add some more structure I have now split up the RISE/reveal.js and the chalkboard bindings in nbconfig. I have added a short chapter to the documentation (good hint), which I hope explains the idea. Additionally I have moved some code blocks into functions to make the whole thing a bit more versatile. So adding custom key bindings to further API calls should now be easier.

If we would only support to make the native key customization via the nbconfig JSON (not nbextension_configurator) the whole thing could easily be simplified and would be more flexible (i.e. just define a list of dicts with keyboard shortcut and API call). But of course this is not as intuitive to use as having predefined bindings in the configurator and if there is not many requests for further customized reveal.js bindings, it's probably not that interesting.

parmentelat commented 4 years ago

as I said I'm going to need to find some time to play with this, but it sounds promising indeed thanks !

parmentelat commented 4 years ago

it's a little embarrassing because our focus is not the master branch but the maint-5.6 instead
my bad entirely, this is not documented anywhere..

anyways, I've merged, I'll see how it goes

parmentelat commented 4 years ago

all right, so here's where i am


at this point what I see as remaining issues is

in any case, if you plan to make any further change, please start from the maint-5.6 branch; feel free to open another PR in that case, as I think it's the most convenient way given that change

thanks !

parmentelat commented 4 years ago

@damianavila it'd help if you were able to do some tests on this on your end

damianavila commented 4 years ago

@theck3r thank you very much for this work!