keypress: Read a single keypress at the terminal

Description Usage Arguments Details Value See Also Examples

Description

It currently only works at Linux/Unix and OSX terminals, and at the Windows command line. see has_keypress_support.

Usage

1
keypress(block = TRUE)

Arguments

block

Whether to wait for a key press, if there is none available now.

Details

The following special keys are supported:

  • Arrow keys: ‘up’, ‘down’, ‘right’, ‘left’.

  • Function keys: from ‘f1’ to ‘f12’.

  • Others: sQuotehome, ‘end’, ‘insert’, ‘delete’, ‘pageup’, ‘pagedown’, ‘tab’, ‘enter’, ‘backspace’ (same as ‘delete’ on OSX keyboards), ‘escape’.

  • Control with one of the following keys: ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘h’, ‘k’, ‘l’, ‘n’, ‘p’, ‘t’, ‘u’, ‘w’.

Value

The key pressed, a character scalar. For non-blocking reads NA is returned if no keys are available.

See Also

Other keypress: has_keypress_support

Examples

1
2
3
4
5
## Not run: 
x <- keypress()
cat("You pressed key", x, "\n")

## End(Not run)


Search within the keypress package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.