Page 1 of 1
return value for iskeydown or waitkeydown
Posted: Tue Sep 08, 2015 12:37 am
by zylesea
I think it would be great if iskeydown and waitkeydown would accept "any" as argument for any key and return the value of the pressed key accordingly. Something like that:
Code: Select all
result$=iskeydown(ANY)
print (result$)
Re: return value for iskeydown or waitkeydown
Posted: Wed Sep 09, 2015 9:23 am
by jalih
zylesea wrote:I think it would be great if iskeydown and waitkeydown would accept "any" as argument for any key and return the value of the pressed key accordingly.
How would multiple simultaneously pressed down keys get handled? One return value is not enough, you would need a state table.
Re: return value for iskeydown or waitkeydown
Posted: Sun Sep 13, 2015 12:34 am
by zylesea
jalih wrote:zylesea wrote:I think it would be great if iskeydown and waitkeydown would accept "any" as argument for any key and return the value of the pressed key accordingly.
How would multiple simultaneously pressed down keys get handled? One return value is not enough, you would need a state table.
I thought to keep it rather simple. Just wait for the very first key hit and report the value of that particular key. IMHO that would ease up things quite much as it would simplify things like
Code: Select all
Repeat
Wait(2)
If IsKeyDown("space")=True Then Break
If IsKeyDown("m")=True Then my_rquit=True
Until my_rquit=True
If my_rquit=True
p_mybuttons()
Else
p_6Stim()
EndIf
to something like that:
Code: Select all
mykey$=waitkeydown(ANY)
switch mykey$
case space: p_6Stim()
case m: p_mybottons()
default: p_mydefaultroutine()
endswitch
In my wildest fantasies the waitkeydown or wait#? function would accept a timeout option, too. Would enable something like
waitkeydown (ANY, 5000)
-> wait for any key to be pressed before 5s time period has passed. If funtion times out give a False return value. But that would be a cherry on top which is not that important.
Re: return value for iskeydown or waitkeydown
Posted: Sat Sep 26, 2015 2:48 pm
by airsoftsoftwair
The ANY option could be added because "Press any key to continue" is certainly a situation that is common in many programs. The timeout option sounds too specific, though. I don't think there are many people who would need this so you should probably implement that on your own.
Re: return value for iskeydown or waitkeydown
Posted: Sun Sep 27, 2015 1:56 am
by zylesea
Sounds good.
And as for the timeout option, as said that would be only the cherry on top, nothing of too high importance.
Re: return value for iskeydown or waitkeydown
Posted: Tue Feb 23, 2016 4:50 pm
by airsoftsoftwair
Code: Select all
- New: WaitKeyDown() and IsKeyDown() accept the magic word "ANY" now to check if any key is down or wait
for any key
Re: return value for iskeydown or waitkeydown
Posted: Wed Mar 02, 2016 7:39 pm
by zylesea
airsoftsoftwair wrote:Code: Select all
- New: WaitKeyDown() and IsKeyDown() accept the magic word "ANY" now to check if any key is down or wait
for any key
Great!