What CGV said.
Perhaps you need also a waitkey() if you want to halt the program until a key is pressed.
Or you can continue your program flow only when enter is pressed. In this case, a while..wend loop could be a solution:
this snip will loop until <enter> is pressed
while not keydown(28)
wend
and this will wait until the <enter> key is depressed:
while keydown(28)
wend
;let's flush also the keyboard buffer
flushkeys()
Using the first one in conjunction with the second, you should have the requested behaviour. Put both in a function, and call it when you need that your program waits until the user presses (and releases) the enter key.
If you make the key code as a parameter for the function, you can then use the same algorithm to wait for any key pressed (and released):
const K_SPACE = 57 ;if I recall good...
const K_ENTER = 28 ;ENTER
;wait until space bar is pressed and released
wait_key(K_SPACE)
;wait until the ENTER key is pressed and released
wait_key(K_ENTER)
.
.
function wait_key(key)
;wait for key being pressed
while not keydown(key)
wend
;wait for key being released
while keydown(key)
wend
;flush the keyboard buffer
flushkeys()
end function
All this theory is valid in case of a static menu, when no screen refresh is requested when displaying the menu itself.
If, instead, you need to refresh the screen in order to show some animation, then you may have to slightly change the code, but basically the concept is the same. You can use a flag to indicate when a certain key has been pressed, and use that flag to change the status of your menu.
Hope this has sense for you,
Sergio.