键盘快捷键可触发R Shiny中的反应流? [英] Keyboard shortcuts to trigger reactive flows in R Shiny?

查看:30
本文介绍了键盘快捷键可触发R Shiny中的反应流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在Windows的Shiny应用程序中触发 F7 Q ?此问题提供了用于使用键盘输入交替切换选项卡的代码,但我对启动反应式感兴趣流.例如,每次用户在键盘上按 Q 时,都会触发"按钮.

Is it possible to have, say, F7 or Q trigger a reactive flow in a Shiny app (in Windows)? This question provides code for alternating tabs with keyboard input, but I am interested in starting reactive flows. For example, a button is 'triggered' every time the user presses Q in the keyboard.

推荐答案

以下是基于的示例这个答案:

library(shiny)

runApp(shinyApp(
  ui = fluidPage(
    tags$script(HTML("$(function(){ 
      $(document).keyup(function(e) {
      if (e.which == 81) {
        $('#button').click()
      }
      });
      })")),
    actionButton("button", "An action button"),
    textOutput("text")),
  server=function(input, output, session) {
    output$text <- renderText({input$button})
  }
))

您可以使用此页面来查找要在javascript代码中使用的密钥代码.在此示例中,如果按q,则单击ID为 button 的元素.

You can use this page to find the keycode you want to use in the javascript code. In this example, if q is pressed, the element with the id button is clicked.

这篇关于键盘快捷键可触发R Shiny中的反应流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆