Skip to content

Instantly share code, notes, and snippets.

Working at home

Fierdy Pandu lightkun10

Working at home
  • Pekanbaru, Indonesia.
View GitHub Profile
lightkun10 / keypress.rb
Created Dec 16, 2019 — forked from acook/keypress.rb
Read keypresses from user in terminal, including arrow keys using pure Ruby. This has since been folded into a much more robust gem called Remedy. &
View keypress.rb
require 'io/console'
# Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char
STDIN.echo = false
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
You can’t perform that action at this time.