Sha256: 52415d368642fdbbc98fe308296f90096e64a62ffe62bca3944d5cd93f491178
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
class Keyboard def self.listen loop do key = Curses.getch case key # move when Curses::Key::UP then yield(:up) when Curses::Key::DOWN then yield(:down) when Curses::Key::RIGHT then yield(:right) when Curses::Key::LEFT then yield(:left) when Curses::KEY_END then yield(:end) when Curses::KEY_HOME then yield(:home) # modify when 9 then yield(:tab) when 32..126 then yield(key) # printable when 10 then yield(:enter) when 263 then yield(:backspace) when Curses::KEY_DC then yield(:delete) # misc when ?\C-d then yield(:"Ctrl+d") when ?\C-f then yield(:"Ctrl+f") when ?\C-g then yield(:"Ctrl+g") when 27 then yield(:escape) when ?\C-s then yield(:"Ctrl+s") when ?\C-w then yield(:"Ctrl+w") when ?\C-q then yield(:"Ctrl+q") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.7 | lib/ruco/keyboard.rb |