Read a single key press from the terminal
> has_keypress_support()  TRUE
> x <- keypress() > cat("You pressed key", x, "\n") You pressed key h
This is unfortunately impossible to do in
- R.app (the builtin OSX GUI),
- RGui (the builtin Windows GUI),
- Emacs ESS, or
stdin() is not a terminal.
In other words, it pretty much only works interactively, in a terminal. The terminal can be pretty much any Linux, OSX, or other Unix terminal or Windows cmd (also called RTerm in R).
Note that not all keys are supported, in particular most of the modifiers
(alt, shift, etc.) are not. Supported special keys are:
- Arrow keys:
left. Available on most keyboards.
- Function keys: from
f12. Available on most keyboards.
- Other special keys:
- Some key combinations with the
- Keys typically not availale on OS X keyboards:
- On Linux and OS X Unicode characters are supported, but not (yet) on
Windows. Unicode characters are returned UTF-8 encoded.
MIT © Gábor Csárdi
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.