The ggkeyboard
package is not on CRAN. Use the install_github
function from devtools
to install it.
# install.packages("devtools")
devtools::install_github("sharlagelfand/ggkeyboard", ref = "main")
The basic keyboard can be created making use of the ggkeyboard
function. The function will create a default keyboard if no arguments are specified.
library(ggkeyboard)
ggkeyboard()
The font size of the keys can be resized with the font_size
argument. Default value is 3. You can also change the font family with font_family
.
library(ggkeyboard)
ggkeyboard(font_size = 2,
font_family = "Arial")
Thre are two layouts available. Default value is layout = "ansi"
but you can also use "iso"
.
library(ggkeyboard)
ggkeyboard(layout = "iso")
You can choose between different pre-built color palettes, such as "pastel"
(default), "serika"
, "wahtsy"
, "cyberpunk"
, "magic"
, "varmilo"
and "t0mb3ry"
. You can also specify custom colors.
serika
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("serika"))
wahtsy
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("wahtsy"))
cyberpunk
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("cyberpunk"))
magic
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("magic"))
varmilo
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("varmilo"))
t0mb3ry
library(ggkeyboard)
ggkeyboard(palette = keyboard_palette("t0mb3ry""))
There are several types of keyboards you can set, such as full
, sixty-percent
, and mac
. Each of them comes with a color palette.
Full (with numeric keyboard)
library(ggkeyboard)
ggkeyboard(full,
palette = keyboard_palette("varmilo"),
font_size = 2.75)
Sixty percent (sixty percent layout)
library(ggkeyboard)
ggkeyboard(sixty_percent,
palette = keyboard_palette("t0mb3ry"),
adjust_text_colour = FALSE)
Mac (based on the Apple magic keyboard)
library(ggkeyboard)
ggkeyboard(mac,
palette = keyboard_palette("magic"))
It is possible to highlight the some keys of the keyboard with the highlight_keys
function.
You can add a border around the selected keys as follows:
library(ggkeyboard)
ggkeyboard() %>%
highlight_keys(c("A", "W", "S", "D"), colour = "red")
You can also add a fill color to the keys with the fill
argument. A good option is to use the rgb
function to add a color with transparency.
library(ggkeyboard)
ggkeyboard() %>%
highlight_keys(c("A", "W", "S", "D"),
colour = "red",
fill = rgb(1, 0, 0, alpha = 0.25))
See also