lib/ruco/keyboard.rb in ruco-0.0.8 vs lib/ruco/keyboard.rb in ruco-0.0.9

- old
+ new

@@ -1,6 +1,8 @@ class Keyboard + A_TO_Z = ('a'..'z').to_a + def self.listen loop do key = Curses.getch code = case key @@ -15,22 +17,18 @@ when Curses::KEY_NPAGE then :page_down when Curses::KEY_PPAGE then :page_up # modify when 9 then :tab + when 13 then :enter # shadows Ctrl+m when 32..126 then key # printable - when 10 then :enter - when 263 then :backspace + when 263, 127 then :backspace # ubuntu / mac when Curses::KEY_DC then :delete # misc - when ?\C-d then :"Ctrl+d" - when ?\C-f then :"Ctrl+f" - when ?\C-g then :"Ctrl+g" + when 0 then :"Ctrl+space" + when 1..26 then :"Ctrl+#{A_TO_Z[key-1]}" when 27 then :escape - when ?\C-s then :"Ctrl+s" - when ?\C-w then :"Ctrl+w" - when ?\C-q then :"Ctrl+q" else key end yield code \ No newline at end of file