require 'Win32API'
def getch
@getch ||= Win32API.new('crtdll', '_getch', [], 'L')
@getch.call
end
while (c = getch) != ?\e
puts "You typed #{c.chr.inspect}"
end
Ruby 在 Windows 下读取键盘输入
最新推荐文章于 2019-08-08 21:59:00 发布
require 'Win32API'
def getch
@getch ||= Win32API.new('crtdll', '_getch', [], 'L')
@getch.call
end
while (c = getch) != ?\e
puts "You typed #{c.chr.inspect}"
end