The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Title: Keyboard Shortcuts for 'shiny'
Version: 0.1.1
Description: Assign and listen to keyboard shortcuts in 'shiny' using the 'Mousetrap' Javascript library.
License: Apache License (≥ 2)
Encoding: UTF-8
RoxygenNote: 7.1.1
Imports: htmltools, shiny, jsonlite
URL: https://github.com/r4fun/keys
BugReports: https://github.com/r4fun/keys/issues
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2021-07-11 17:49:30 UTC; tlittlef
Author: Tyler Littlefield [aut, cre] (Author of Javascript wrapper), Colin Fay ORCID iD [aut], Craig Campbell [cph] (Author of JavaScript code)
Maintainer: Tyler Littlefield <tylerlittlefield@hey.com>
Repository: CRAN
Date/Publication: 2021-07-11 18:00:02 UTC

Add a key binding from the server side

Description

Add a key binding from the server side

Usage

addKeys(inputId, keys, session = shiny::getDefaultReactiveDomain())

removeKeys(keys, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

The input slot that will be used to access the value.

keys

A character vector of keys to bind. Examples include, command, command+shift+a, ⁠up down left right⁠, and more.

session

The session object passed to function given to shinyServer. Default is getDefaultReactiveDomain().


Create a keys input control

Description

Create a key input that can be used to observe keys pressed by the user.

Usage

keysInput(inputId, keys, global = FALSE)

Arguments

inputId

The input slot that will be used to access the value.

keys

A character vector of keys to bind. Examples include, command, command+shift+a, ⁠up down left right⁠, and more.

global

Should keys work anywhere? If TRUE, keys are triggered when inside a textInput.

Examples

## Not run: 
ui <- fluidPage(
  keysInput("keys", c(
    "1",
    "2",
    "3",
    "command+shift+k",
    "up up down down left right left right b a enter"
  )),
)

server <- function(input, output, session) {
  observeEvent(input$keys, {
    print(input$keys)
  })
}

shinyApp(ui, server)

## End(Not run)


Create a keys recorder input control

Description

Create a key input that can be used to record keys pressed by the user.

Usage

keysRecordInput(inputId)

recordKeys(inputId, session = shiny::getDefaultReactiveDomain())

Arguments

inputId

The input slot that will be used to access the value.

session

The session object passed to function given to shinyServer. Default is getDefaultReactiveDomain().

Examples

if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    useKeys(),
    keysRecordInput("recorder"),
    keysInput("keys", "command+shift+k"),
    actionButton("record", "Record keys")
  )

  server <- function(input, output, session) {
    observeEvent(input$record, {
      print("recording keys...")
      recordKeys("recorder")
    })
    observeEvent(input$recorder, {
      print("adding keys...")
      addKeys("keys", input$recorder)
    })
    observeEvent(input$keys, {
      print(input$keys)
    })
  }

  shinyApp(ui, server)
}

Pause or Unpause Keys

Description

These functions allow to pause and unpause keyboard watching

Usage

pauseKey(session = shiny::getDefaultReactiveDomain())

unpauseKey(session = shiny::getDefaultReactiveDomain())

Arguments

session

The session object passed to function given to shinyServer. Default is getDefaultReactiveDomain().

Examples

if (interactive()){
library(shiny)
ui <- fluidPage(
  useKeys(),
  keysInput("keys", letters),
  actionButton("pause", "Pause"),
  actionButton("unpause", "Unpause")
)

server <- function(input, output, session) {
  observeEvent(input$keys, {
    print(input$keys)
  })
  observeEvent(input$pause, {
    pauseKey()
  })
  observeEvent(input$unpause, {
    unpauseKey()
  })

}

shinyApp(ui, server)
}

Use Keys in your application

Description

This function adds the keys dependencies to your application

Usage

useKeys()

Value

An html singleton

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.