remark icon indicating copy to clipboard operation
remark copied to clipboard

disable keyboard shortcuts

Open punkish opened this issue 5 years ago • 7 comments

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.

punkish avatar Oct 18 '18 05:10 punkish

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

emitanaka avatar Oct 18 '18 05:10 emitanaka

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 [email protected] 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 avatar Oct 18 '18 06:10 punkish

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 avatar Oct 21 '18 22:10 punkish

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 avatar Nov 16 '18 21:11 punkish

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.

punkish avatar Nov 17 '18 09:11 punkish

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?

peterj avatar Dec 17 '19 19:12 peterj

@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!!

py9mrg avatar Apr 09 '21 14:04 py9mrg