Key repeat?

Blitz3D Forums/Blitz3D Beginners Area/Key repeat?

collimic(Posted 2012) [#1]
I am looking for a way to get the status of a single key on the keyboard. I want to be able to press p to pause the game and p again to un-pause the game or have the up arrow make we walk until I press it again.

I have searched and have not found away to reuse the key for another purpose.

If you can help in anyway that would be great.

I am very new to programming and I am a bit overwhelmed.

Thank you


Stevie G(Posted 2012) [#2]
Look up Keyhit and Flushkeys.

A quick and dirty example..

If Keyhit( 25 )
;Display Pause Information
Flushkeys()
repeat : until keyhit( 25 )
Endif


Zethrax(Posted 2012) [#3]
For what you're trying to do there, the best approach might be to use a variable as a toggle.

[bbcode]toggle = False
While Not KeyHit( 1 ) ; Exit the program if the ESCAPE key is pressed.
If KeyHit( 57 ) ; Press the SPACEBAR to toggle the variable's state.
toggle = Not toggle ; Invert the boolean (True/False) state of the variable.
EndIf

If toggle ; Print some text depending on the state of the 'toggle' variable.
Print "Toggle: On"
Else
Print "Toggle: Off"
EndIf

Delay( 20 ) ; This is just here to give the OS room to breath.
Wend
End[/bbcode]


collimic(Posted 2012) [#4]
Thank you Zethrax your code worked great.


cryptadone(Posted 2014) [#5]
and do a loop for freeze the program.