Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getkp

Get Keypress


Description

Listen for a keypress, then apply keypress to a function or echo 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

getkp(fn = list(), echo = FALSE)

Arguments

fn

list of named functions

echo

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

Value

character naming the key that was pressed (invisibly).

Examples

f <- list(
	 'up'    = function(){mv(row=-1)},
  'down'  = function(){mv(row=-1)},
	 'left'  = function(){mv(col=-1)},
	 'right' = function(){mv(col=1)}
)
## Not run: 
getkp(fn=f, echo=FALSE)

## End(Not run)

cursr

Cursor and Terminal Manipulation

v0.1.0
MIT + file LICENSE
Authors
Chris Mann
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.