Textbox in SHiny

Capturing input for text box in shiny
How to capture input the moment i press enter in R shiny for text boxes?
kindly give detail code for that .

may be you want smth like:
textAreaInput("SQL_from_DB","The script to download input data", "text wich'll be shown every time you star shiny", rows = 10, columns = 30)

I'm not sure if this is what you're asking or not but you can use some javascript code to simulate a click of an actionButton when you hit the return key from inside a textInput.

Save this js file in your app's working directory as returnClick.js supplying the ids you will use for your textInput and actionButton. In this case myText and myButton.

# returnClick.js
$(document).keyup(function(event) {
    if ($("#myText").is(":focus") && (event.keyCode == 13)) {

The following app will render the text in your textInput but only when the actionButton is clicked, however you don't need to manually click the button, you can just hit the return key when inside the text box.

# app.R

ui <- fluidPage(
  # include your js script

  textInput("myText", "Text Input", placeholder = "Enter text then hit return"),
  actionButton("myButton", "Go!"),

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

shinyApp(ui, server)
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.