Title: Wait for a Key Press in a Terminal
Version: 1.3.1
Author: Gábor Csárdi [aut, cre], Jon Griffiths [aut]
Maintainer: Gábor Csárdi <csardi.gabor@gmail.com>
Description: Wait for a single key press at the 'R' prompt. This works in terminals, but does not currently work in the 'Windows' 'GUI', the 'OS X' 'GUI' ('R.app'), in 'Emacs' 'ESS', in an 'Emacs' shell buffer or in 'R Studio'. In these cases 'keypress' stops with an error message.
License: MIT + file LICENSE
URL: https://github.com/gaborcsardi/keypress#readme
BugReports: https://github.com/gaborcsardi/keypress/issues
RoxygenNote: 7.1.2
Encoding: UTF-8
Suggests: covr
NeedsCompilation: yes
Packaged: 2023-12-11 00:55:01 UTC; gaborcsardi
Repository: CRAN
Date/Publication: 2023-12-11 03:40:03 UTC

Check if the current platform/terminal supports reading single keys.

Description

Check if the current platform/terminal supports reading single keys.

Usage

has_keypress_support()

Details

Supported platforms:

Not supported:

Value

Whether there is support for waiting for individual keypressses.

See Also

Other keypress function: keypress()

Examples

has_keypress_support()

Read a single keypress at the terminal

Description

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

Usage

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:

Value

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

See Also

Other keypress function: has_keypress_support()

Examples


x <- keypress()
cat("You pressed key", x, "\n")


Call a function with echo suppressed

Description

For Linux/Unix and OSX terminals, suppress key echoes from the terminal.

Usage

without_echo(expr)

Arguments

expr

Expression to evaluate without terminal echo.

Details

You will need to set echo to FALSE if you want the R script to handle all of the keypress-related behaviour, without any keys being echoed in the terminal by the operating system, when using non-blocking keypress. This is not necessary when running in a Windows command prompt, and will be safely ignored.