Skip to content

Instantly share code, notes, and snippets.

@drbrain
Created May 8, 2013 23:17
Show Gist options
  • Save drbrain/5544411 to your computer and use it in GitHub Desktop.
Save drbrain/5544411 to your computer and use it in GitHub Desktop.
require 'io/console'
def read_char
$stdin.noecho do
$stdin.raw do
input = $stdin.getc.chr
if input == "\e" then
input << $stdin.read_nonblock(3) rescue nil
input << $stdin.read_nonblock(2) rescue nil
end
return input
end
end
end
system("irb")
c=read_char
p c
system("irb")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment