gnab / remark

A simple, in-browser, markdown-driven slideshow tool.
http://remarkjs.com
MIT License
12.71k stars 857 forks source link

disable keyboard shortcuts #544

Open punkish opened 6 years ago

punkish commented 6 years ago

I'd like to disable keyboard shortcuts for a presentation. How can I do that?

Long story: I am building a presentation that allows user input in fields or clicks on elements on the slide, and then generate responses. This way, I can do an interactive presentation/demo. For example, I may have an input field on a slide where the user enters text, clicks a button, and a response is shown below the field. Right now, when I try to enter text in the input field, if the keystroke happens to be a remarkjs keyboard shortcut, the command is fired. For example, if I enter 'h' in the field, help is shown. Obviously, I don't want that. So, I'd like to disable all keyboard shortcuts and cursor clicks except, perhaps, the arrow keys to move the slides to next or prev.

Also, if someone has built such an interactive presentation, I'd love to see it to get ideas. Many thanks.

emitanaka commented 6 years ago

Can you wrap it around in an iframe? Essentially that was what I did here to stop the interactivity. I have used plotly to get interactive graphs as here but you can have a table with search option as Yihui had here in his slides (albeit wrapping in iframes first so the keyboard shortcuts do not get triggered).

punkish commented 6 years ago

Hmmmm, I had not thought of iframes. I could try that as a last resort but I’d prefer not to use iframes as that would mess up my slides structure and raw code. I’d prefer to simply disable keyboard shortcuts via a configuration option

Update: I inspected Yihui's slides. That is exactly the behavior I would want. But, I didn't notice any iFrames in those slides. What am I missing?

On Oct 18, 2018, at 7:44 AM, Emi Tanaka notifications@github.com wrote:

Can you wrap it around in an iframe? Essentially that was what I did here to stop the interactivity. I have used plotly to get interactive graphs as here but you can have a table with search option as Yihui had here in his slides (albeit wrapping in iframes first so the keyboard shortcuts do not get triggered).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

punkish commented 5 years ago

ok, I figured out how to use the iframe, and yes, it is working as expected. However, as I noted earlier, it makes for a really messy code because now I have a slew of html files, one for each slide with an iframe src instead of a single file. It would be so much better to simply disable the keyboard shortcuts via a configuration param.

punkish commented 5 years ago

revisiting this issue – while using iframes does work, I'd rather disable keyboard shortcuts, preferably on certain slides only. The reason is that using many iframes with their own js and css uses up way more memory. It also makes it difficult keep the styles consistent without loading the same css for each iframe src.

punkish commented 5 years ago

OK, I figured out a way forward. I commented out key definitions in keyboard.js and rebuilt the project. The resulting remark js responds only to the left and right arrow keys as I need them for navigating through the slideshow. Now I can type and click buttons on forms in a slide without triggering a slideshow action. I just have to be careful not to use the left and right arrow keys to move within a form field.

It would be really nice if there were a configuration option to do this at runtime.

peterj commented 4 years ago

Marking this as a feature request. This would involve adding configuration setting(s) to disable keyboard shortcuts. I think the question would be how fine-grained control would one want to have - would disabling everything and keeping left/right be enough?

py9mrg commented 3 years ago

@peterj not sure if this is any help, but the R package xaringanExtra has a function that allows the slides to be editable - and seems to deactivate the keyboard shortcuts when editing (although I have no idea how). You can wrap a table (e.g. a DataTable generated by the DT package) in this and the editable parts no longer respond to keyboard shortcuts. Although the search box still does!!