Giter Site home page Giter Site logo

keypress's Introduction

keypress

Read a single key press from the terminal

Linux Build Status Windows Build status CRAN RStudio mirror downloads

Installation

install.packages("keypress")

Usage

> has_keypress_support()
[1] TRUE
> x <- keypress()
> cat("You pressed key", x, "\n")
You pressed key h

Support

This is unfortunately impossible to do in

  • RStudio,
  • R.app (the builtin OSX GUI),
  • RGui (the builtin Windows GUI),
  • Emacs ESS, or
  • if 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).

Keys

Note that not all keys are supported, in particular most of the modifiers (alt, shift, etc.) are not. Supported special keys are:

  • Arrow keys: up, down, right, left. Available on most keyboards.
  • Function keys: from f1 to f12. Available on most keyboards.
  • Other special keys: enter, backspace, escape, tab.
  • Some key combinations with the CONTROL key: ctrl-a, ctrl-b, ctrl-c, ctrl-d, ctrl-e, ctrl-f, ctrl-h, ctrl-k, ctrl-l, ctrl-n, ctrl-p, ctrl-t, ctrl-u, ctrl-w.
  • Keys typically not availale on OS X keyboards: home, end, insert, delete, pageup, pagedown.
  • On Linux and OS X Unicode characters are supported, but not (yet) on Windows. Unicode characters are returned UTF-8 encoded.

License

MIT © Gábor Csárdi

keypress's People

Contributors

gaborcsardi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.