Created
February 13, 2019 09:03
-
-
Save giann/4e226baf318a4e3592c7058ee0defee3 to your computer and use it in GitHub Desktop.
Echo keyboard input (useful to print out escape codes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.execute("/usr/bin/env stty raw -echo 2> /dev/null") | |
local term = require "term" | |
local function loop() | |
local char | |
repeat | |
term.cursor.save() | |
char = io.stdin:read(1) | |
print("- " .. char:byte(1) .. ": " .. char) | |
term.cursor.restore() | |
term.cleareol() | |
until char == "\r" | |
end | |
pcall(loop) | |
os.execute("/usr/bin/env stty sane") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment