Discord
Login
Community
DARK THEME

do something if press any key

is there a kind of list that can tell all the variables that the keyboard.press.# has? i was thinking about something like keyboard.press.any

list = []
for key in keyboard
  if keyboard[key] == 1 then
    list.push(key)
  end
end

Will do the job, though you'll get duplicates (For example, if you press E, you will run the code for "E" and "KEY_E". If you press up, it will return "UP", "KEY_UP", and "ARROW_UP". W will return "UP", "KEY_W", and "W").

thank you! do you know any lua way to do this? i need just a check so something like a bool function

function anyKeyPress() check = false for key, #keyboard do if keyboard[key] == 1 then check = true end end return check end

but there is a problem with the for:

expected near '#'

how i deal with this?

My best guess is that keyboard isn't available in lua, and it's under a different name or something? Sorry, I don't know much about lua in microscript

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community