ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

opening a bsModal with a key stroke #106

Open professorbeautiful opened 5 years ago

professorbeautiful commented 5 years ago

Can one open a bsModal using a key for a trigger (I like control-D for the purpose). Trying to make improvement to my shinyDebuggingPanel package. I currently detect control-D and use conditionalPanel with an input.ctrlDpressed condition, and extra code to navigate to the top of the page where the debugging panel is. But I'd like it to appear in a bsModal instead of a conditionalPanel, so that the panel can be opened from anywhere on the page. I've tried simply using "ctrlDpressed" as the trigger, but I guess it really has to be a button or link.

var ctrlDpressed = false;

$(document).on("keyup", function (event) { eventSaved = event; x = event.which || event.keyCode; keyVar = x; eventSaved = event; if(x==68 && event.ctrlKey) { // control d ctrlDpressed = ! ctrlDpressed; // toggle Shiny.onInputChange("ctrlDpressed", ctrlDpressed); }