R/add_key.R

Defines functions removeKeys addKeys

Documented in addKeys removeKeys

#' Add a key binding from the server side
#'
#' @inheritParams keysInput
#' @inheritParams shiny::updateActionButton
#' @export
#' @rdname updateKeys
addKeys <- function(
  inputId,
  keys,
  session = shiny::getDefaultReactiveDomain()
){
  if (is.null(session)) alert_null_session()

  lapply(
    keys, function(x){
      session$sendCustomMessage(
        "add_mousetrap_binding",
        list(
          id = inputId,
          keys = x
        )
      )
    }
  )

}

#' @export
#' @rdname updateKeys
removeKeys <- function(
  keys,
  session = shiny::getDefaultReactiveDomain()
){
  if (is.null(session)) alert_null_session()

  lapply(
    keys, function(x){
      session$sendCustomMessage(
        "remove_mousetrap_binding",
        list(
          keys = x
        )
      )
    }
  )

}

Try the keys package in your browser

Any scripts or data that you put into this service are public.

keys documentation built on July 12, 2021, 1:05 a.m.