How can I read a single char from the console without pressing enter / return?
In ruby I would just use:
require 'io/console'
input = STDIN.getch
How can I read a single char from the console without pressing enter / return?
In ruby I would just use:
require 'io/console'
input = STDIN.getch
Try this:
char = STDIN.raw &.read_char
p char
© 2022 - 2024 — McMap. All rights reserved.
STDIN.ready?
? When I am reading Meta/Alt characters or Shifted-Fn keys, I keep reading whileSTDIN.ready?
and return with the collected keys when it is not ready. – Sarco