Created
May 8, 2013 23:17
-
-
Save drbrain/5544411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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