hi, i need help with the keyboard, i need use a better fuction that Win32API.new('user32','GetKeyState',['L'],'L'), i want only the key pressed, not all the keyboard status, like Win32API.new('crtdll', '_kbhit', [ ], 'L').Call but this one only work in console not window, some one have a better way?
I use it to let the player set the name of the main character (it work)
Teclado = [
["enter",0x0D],
[" ",0x20],
["delete",0x08],
["a",0x41],
["b",0x42],
["c",0x43],
["d",0x44],
["e",0x45],
["f",0x46],
["g",0x47],
["h",0x48],
["i",0x49],
["j",0x4A],
["k",0x4B],
["l",0x4C],
["m",0x4D],
["n",0x4E],
["o",0x4F],
["p",0x50],
["q",0x51],
["r",0x52],
["s",0x53],
["t",0x54],
["u",0x55],
["v",0x56],
["w",0x57],
["x",0x58],
["y",0x59],
["z",0x5A]
]
def self.leer_teclado
i=0
while(i<Teclado.length)
state = Win32API.new('user32','GetKeyState',['L'],'L')
if (state.call(Teclado[1])!=0)&&(state.call(Teclado[1])!=1)
return Teclado[0]
break
end
i += 1
end
return false
end
I use it to let the player set the name of the main character (it work)
Teclado = [
["enter",0x0D],
[" ",0x20],
["delete",0x08],
["a",0x41],
["b",0x42],
["c",0x43],
["d",0x44],
["e",0x45],
["f",0x46],
["g",0x47],
["h",0x48],
["i",0x49],
["j",0x4A],
["k",0x4B],
["l",0x4C],
["m",0x4D],
["n",0x4E],
["o",0x4F],
["p",0x50],
["q",0x51],
["r",0x52],
["s",0x53],
["t",0x54],
["u",0x55],
["v",0x56],
["w",0x57],
["x",0x58],
["y",0x59],
["z",0x5A]
]
def self.leer_teclado
i=0
while(i<Teclado.length)
state = Win32API.new('user32','GetKeyState',['L'],'L')
if (state.call(Teclado[1])!=0)&&(state.call(Teclado[1])!=1)
return Teclado[0]
break
end
i += 1
end
return false
end