Method: TTY::Reader#read_keypress
- Defined in:
- lib/tty/reader.rb
#read_keypress(echo: false, raw: true, nonblock: false) ⇒ String Also known as: read_char
Read a keypress including invisible multibyte codes and return a character as a string. Nothing is echoed to the console. This call will block for a single keypress, but will not wait for Enter to be pressed.
184 185 186 187 188 189 190 191 192 |
# File 'lib/tty/reader.rb', line 184 def read_keypress(echo: false, raw: true, nonblock: false) codes = unbufferred do get_codes(echo: echo, raw: raw, nonblock: nonblock) end char = codes ? codes.pack("U*") : nil trigger_key_event(char) if char char end |