Read from keyboard : Win32API « Windows Platform « Ruby






Read from keyboard


require 'Win32API'

def getch
  @getch ||= Win32API.new('crtdll', '_getch', [], 'L')
  @getch.call
end

while (c = getch) != ?\e
  puts "You typed #{c.chr.inspect}"
end

 








Related examples in the same category

1.Use Win32API to get a pointer a function
2.Working with Microsoft Windows: open a dialog box:
3.Open a dialog and check the result
4.Get cursor position with Win32API