return value for iskeydown or waitkeydown

Feature requests for future versions of Hollywood can be voiced here
Post Reply
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

return value for iskeydown or waitkeydown

Post 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$)
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: return value for iskeydown or waitkeydown

Post 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.
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: return value for iskeydown or waitkeydown

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: return value for iskeydown or waitkeydown

Post 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.
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: return value for iskeydown or waitkeydown

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: return value for iskeydown or waitkeydown

Post 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
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: return value for iskeydown or waitkeydown

Post 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!
Post Reply