I am currently using this code to grab key-strokes, but I am missing e.g. Shift/Alt keys like Ctrl+Shift+S, Ctrl+Shift+↑, Alt+S, etc.
require 'curses'
Curses.noecho
Curses.raw
Curses.stdscr.keypad(true)
Curse.nonl
count = 0
loop do
count = (count + 1) % 20
key = Curses.getch
break if key == ?\C-c
Curses.setpos(count,0)
Curses.addstr("#{key.inspect} ");
end
Is there any way to capture them all ?
Also: how can I distinguish Ctrl+J / Ctrl+M from Ctrl+Enter / Enter, which give the same key-codes (10
/13
)?