2011-01-05 53 views

回答

3

Ctrl + S鍵通常由終端抓起,所以你必須把Curses原始模式來捕捉關鍵。這裏是一個例子:

#!/usr/bin/ruby 

require 'curses' 

Curses.raw # intercept everything 
Curses.noecho 
loop do 
    case Curses.getch 
    when ?q  then break 
    when ?b  then Curses.addch ?b 
    when ?\C-s then Curses.addstr "^s" # Ctrl+S 
    end 
end