Created
November 30, 2018 15:36
-
-
Save PaulC91/bd5035875305dfad504f1a3794233186 to your computer and use it in GitHub Desktop.
return key trigger actionButton click in shiny example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- fluidPage( | |
tags$head(includeScript("returnClick.js")), | |
textInput("myText", "", placeholder = "Enter text then hit return", width = "100%"), | |
actionButton("myButton", "Go!"), | |
verbatimTextOutput("textOutput") | |
) | |
server <- function(input, output, session) { | |
output$textOutput <- renderText({ | |
input$myButton # take a dependency on the button click | |
# isolate text input to only re-render when button is clicked | |
isolate(input$myText) | |
}) | |
} | |
shinyApp(ui, server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).keyup(function(event) { | |
if ($("#myText").is(":focus") && (event.keyCode == 13)) { | |
$("#myButton").click(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment