- require 'Win32API'
- def getch
- @getch ||= Win32API.new('crtdll', '_getch', [], 'L')
- @getch.call
- end
- while (c = getch) != ?\\e
- puts "You typed #{c.chr.inspect}"
- end
- #该片段来自于http://www.codesnippet.cn/detail/040220132108.html
来源: http://www.codesnippet.cn/detail/040220132108.html