Learn R Programming

cursr (version 0.1.0)

getkpl: Loop a Keypress

Description

Maintain a loop that listens for a keypress, then applies the keypress to a function or echoes it to the terminal screen. The user must be in a terminal to use getkp; it will not work in RStudio or the R GUI. All actions within R are halted until the keypress is returned.

Usage

getkpl(escape = "escape", fn = list(), echo = FALSE)

Arguments

escape

vector of character keypresses that escape the loop. The default is "escape" key.

fn

list of named functions

echo

whether the keypress should be echoed to the screen if not found in list

Value

NULL

Examples

Run this code
# NOT RUN {
f <- list(
	 'up'    = function(){mv(row=-1)},
  'down'  = function(){mv(row=-1)},
	 'left'  = function(){mv(col=-1)},
	 'right' = function(){mv(col=1)}
)
# }
# NOT RUN {
getkpl(escape = c("escape", "enter"), fn=f, echo=FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab