An open API service indexing awesome lists of open source software.

https://github.com/eudoxia0/terminal-keypress

Read keyboard events in the terminal from Common Lisp
https://github.com/eudoxia0/terminal-keypress

console keyboard keypress lisp terminal

Last synced: 3 months ago
JSON representation

Read keyboard events in the terminal from Common Lisp

Awesome Lists containing this project

README

        

# terminal-keypress

Read keypresses from the terminal using [trivial-raw-io][trio].

# Overview

This is a library for reading semi-raw user input from terminals. Semi-raw as
in, we can't detect if the user pressed the Control key alone, and
the function keys are a mystery.

What is supported, however, is:

1. Regular characters
2. Control+[key]
3. Alt+[key]
4. Control+Alt+[key]

# Usage

```lisp
CL-USER> (terminal-keypress:read-event)
;; Press 't'

#S(TERMINAL-KEYPRESS::KEYPRESS
:BYTES #(116)
:CHARACTER #\t
:CONTROL NIL
:ESCAPE NIL)

CL-USER> (terminal-keypress:read-event)
;; Press 'Control-t'

#S(TERMINAL-KEYPRESS::KEYPRESS
:BYTES #(20)
:CHARACTER #\T
:CONTROL T
:ESCAPE NIL)

CL-USER> (terminal-keypress:read-event)
;; Press 'Alt-t'

#S(TERMINAL-KEYPRESS::KEYPRESS
:BYTES #(27 116)
:CHARACTER #\t
:CONTROL NIL
:ESCAPE T)

CL-USER> (terminal-keypress:read-event)
;; Press 'Control-Alt-t'

#S(TERMINAL-KEYPRESS::KEYPRESS
:BYTES #(27 20)
:CHARACTER #\T
:CONTROL T
:ESCAPE T)
```

# License

Copyright (c) 2016–2017 Fernando Borretti

Licensed under the MIT License.

[trio]: http://quickdocs.org/trivial-raw-io/