I am trying to implement a R Shiny app that will automatically read the content of the clipboard when the users hit "ctrl+c". In the app, I need to somehow observe the change of clipboard content. I googled but with no luck.
I know that content of the clipboard can be assessed via readClipboard() function, but I don't know how to detect the change in clipboard in a R Shiny App.
Below I have show some simple R Shiny code to observe a button click and update the text output; but I don't know how to observe a change in Clipboard.
Thank you for all your help in advance.
ui <- fluidPage(
actionButton(inputId = "dummy_button", label = "This is a button"),
verbatimTextOutput(outputId = "detector")
)
server <- function(input, output,session) {
# create a reactiveVal of count
counter <- reactiveVal(0)
observeEvent(input$dummy_button, {
#update the counter after button click
counter(counter() + 1)
output$detector <- renderPrint({
paste("button clicked", counter(), "times")
})
})
}
# Run the application
shinyApp(ui = ui, server = server)
The text output should be something like "The content in clipboard has changed x times"