R/keycap.R

Defines functions keycap

Documented in keycap

#' Keycap emoji sequence
#'
#' @param x character, must be a number between 0 and 10, "#", or "*".
#'
#' @export
#' @return a keycap version of `x`
#'
#' @details
#' This function is vectorized.
#'
#' @examples
#' keycap(6)
#' keycap('#')
#'
#' keycap(1:10)
keycap <- function(x) {
  choices <- c("#", "*", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
  x <- as.character(x)

  keycaps <- emoji::emojis$emoji[emoji::emojis$subgroup == "keycap" &
                                 emoji::emojis$qualified == "fully-qualified"]

  keycaps[match(x, choices)]
}

Try the emoji package in your browser

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

emoji documentation built on Oct. 30, 2024, 9:28 a.m.