Is there any function that will return a buffered input from the keyboard in the same way that the BASIC function Inkey$ would do ?
I have two problems with using InKeyStr()
1. It echos to the screen the characters being input
2. It needs a RETURN or ENTER key to end the input (so you can't have any other processes going on while waiting for an input, your code is effectively halted.
Writing a tight loop to test for keypresses with IsKeyDown() is not very effective, uses a lot of processor time, and if you type quickly, it misses keypresses.
Any ideas ?
Inkey$ function
-
- Posts: 32
- Joined: Mon Feb 15, 2010 4:14 pm
- Location: Nottinghamshire, UK
- Contact:
Re: Inkey$ function
Why not using an event to monitor keypresses?
This should resolve your problem
Code: Select all
Function check_key(msg)
Print("Key pressed:", msg.key)
EndFunction
installEventHandler( { OnKeyDown = check_key } )
Repeat
WaitEvent()
Forever
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
-
- Posts: 32
- Joined: Mon Feb 15, 2010 4:14 pm
- Location: Nottinghamshire, UK
- Contact:
Re: Inkey$ function
Thanks, that looks very useful, looks a lot better way of doing things