r4fun / keys

:keyboard: Keyboard Shortcuts for 'shiny'
https://r4fun.github.io/keys/
Other
45 stars 6 forks source link

Add nullOnKeyRelease option #18

Open DavidBarke opened 3 months ago

DavidBarke commented 3 months ago

This pull requests adds the option nullOnKeyRelease to keysInput and addKeys. If this option is set, the Shiny input will be set to NULL after any of the bound keys is released.

This option enables to detect whether a key is pressed. Consider an actionButton whose action depends on whether ctrl is pressed or not. Without this option, the Shiny input is "ctrl" as long as ctrl has been pressed any time in the past. With this option, the Shiny input is only "ctrl" if ctrl is still pressed and else NULL.