-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
term: add key_pressed, enable_echo #23171
Conversation
Example usage: module main
import term
import time
fn main() {
defer {
term.enable_echo(true)
}
term.enable_echo(false)
for {
// non-blocking mode, no echo
x := term.key_pressed(false, false)
if x >= 0 {
println(x)
}
time.sleep(1 * time.millisecond)
}
}
|
I'm using this variation to test: module main
import term
import time
fn main() {
unbuffer_stdout()
term.enable_echo(false)
defer {
term.enable_echo(true)
}
for {
// non-blocking mode, with echo
x := term.key_pressed(false, true)
if x == 0 {
break
}
if x > 0 {
println(x)
}
time.sleep(16 * time.millisecond)
print('\r${time.now()} | ')
}
println('done')
} (pressing Ctrl-D exits the loop, without having to reset the terminal, which is needed if I stop it with Ctrl-C) |
Thanks, add it to examples |
…h named fields for term.key_pressed, instead of 2 boolean arguments
It seems that the keycodes that are used for F1..F12 + arrows + home/end keys, are different than the ones that terminals on linux/macos use 🤔 . |
Unfortunately it is more of a framework (with callbacks), not a library 🤔 . |
Feature/Enhancement Request
#21826
TODO: add tests, but I don't know how ....
Huly®: V_0.6-21607