This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
NonStopGamer's profile picture

Simulate a Key Press

Started by NonStopGamer, 11 March 2013 - 09:36 AM
NonStopGamer #1
Posted 11 March 2013 - 10:36 AM
Does anyone know how to Simulate a Keypress/event?

for example, something like press("w") that will be as if you actually pressed the key

that way, i can use redstone to use as keys for games.
Lyqyd #2
Posted 11 March 2013 - 10:49 AM
You can use queueEvent. It won't simulate actual keypresses, but it can generate the events.

For instance, `os.queueEvent("char", "w")` would queue an event that looked like someone had pressed the w character (though, it would, of course, lack the key event preceeding it unless you queued that also).
NonStopGamer #3
Posted 12 March 2013 - 11:22 AM
Ok thanks so much!!!!!