I am in a Ruby script something like:
something = gets # or STDIN.gets
puts something
def arrow_pressed
puts "arrow totally pressed"
end
Once the user prompt exists I want all keyboard input to happen normally except for the arrow keys. If those are pressed I don't want anything to appear in the terminal (e.g. ^[[A
). I just want to execute my arrow_pressed
method. And I want to execute it without the user needing to hit Return
I already tried this gist - which works well except that even after changing it to let through most keystrokes normally, I still can't get Backspace
(or other specials) to work.
I'm happy to use something other than gets
(a library or whatever). Any help would be appreciated!