here you go, a function that will let you check if any alphanumeric key was pressed - i even added an option to allow you to specify if it's case sensitive or not
(i used the g_InKey as it's more user friendly than trying to memorise / workout which scan code you need so the actual end use function is way nicer but scancode will allow you to target the entire keyboard so it's probably best to have a function for both)
function GetKeyPressed(key, ignorecase)
key = key or ""
ignorecase = ignorecase or false
local inkey = g_InKey
if ignorecase then
key = string.lower(key)
inkey = string.lower(g_InKey)
end
local waspressed
if inkey == key and lastpressed ~= key then
waspressed = true
else
waspressed = false
end
lastpressed = g_InKey
return waspressed
end
example usages
(checks for specifically the "R" key being pressed)
local key = GetKeyPressed("R")
if key then
Prompt("pressed : "..g_InKey)
end
(checks for the "R" or "r" key(s) being pressed)
local key = GetKeyPressed("R", true)
if key then
Prompt("pressed : "..g_InKey)
end
(checks for any alphanumeric key being pressed)
local key = GetKeyPressed(g_InKey, true)
if key then
Prompt("pressed : "..g_InKey)
end