Skip to content

Read keyboard events in the terminal from Common Lisp

Notifications You must be signed in to change notification settings

eudoxia0/terminal-keypress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terminal-keypress

Read keypresses from the terminal using trivial-raw-io.

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

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.

About

Read keyboard events in the terminal from Common Lisp

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published