getAsyncKeyState = Win32API.new('user32.dll', 'GetAsyncKeyState', 'i', 'i') if (1...0xFF).any? {|i| getAsyncKeyState.call(i) != 0} print("Any Key DOWN !") # do sth... end