Sha256: 2f44772116faef61165217d0ec4bbbc3fb0b13fa3249c1db9ee34b770327c28b
Contents?: true
Size: 833 Bytes
Versions: 1
Compression:
Stored size: 833 Bytes
Contents
class Keyboard A_TO_Z = ('a'..'z').to_a def self.listen loop do key = Curses.getch code = case key # move when Curses::Key::UP then :up when Curses::Key::DOWN then :down when Curses::Key::RIGHT then :right when Curses::Key::LEFT then :left when Curses::KEY_END then :end when Curses::KEY_HOME then :home 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 263, 127 then :backspace # ubuntu / mac when Curses::KEY_DC then :delete # misc when 0 then :"Ctrl+space" when 1..26 then :"Ctrl+#{A_TO_Z[key-1]}" when 27 then :escape else key.chr # printable end yield code end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.12 | lib/ruco/keyboard.rb |