Skip to content

Instantly share code, notes, and snippets.

View mrowa44's full-sized avatar

Justyna Rachowicz mrowa44

  • Kraków, Poland
View GitHub Profile
@mrowa44
mrowa44 / read_char.rb
Created April 5, 2015 14:54
Non-stopping input (even special characters, arrows etc.)
require 'io/wait'
def read_char
system "stty raw -echo"
if $stdin.ready?
char = $stdin.getc.chr
if char == "\e"
extra_thread = Thread.new do
char += $stdin.getc.chr
char += $stdin.getc.chr