Read keypresses from the terminal using trivial-raw-io.
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:
- Regular characters
- Control+[key]
- Alt+[key]
- Control+Alt+[key]
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)
Copyright (c) 2016–2017 Fernando Borretti
Licensed under the MIT License.