Keyboard input/Keypress check: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎{{header|PureBasic}}: Added PureBasic)
m (→‎{{header|ZX Spectrum BASIC}}: corrected language name)
Line 6: Line 6:
=={{header|BASIC}}==
=={{header|BASIC}}==


==={{header|ZX Spectrum BASIC}}===
==={{header|ZX Spectrum Basic}}===


10 REM k$ will be empty, if no key has been pressed
<lang basic>10 REM k$ will be empty, if no key has been pressed
20 LET k$ = INKEY$
20 LET k$ = INKEY$</lang>


[[Category:Keyboard Input]]
[[Category:Keyboard Input]]

=={{header|PureBasic}}==
=={{header|PureBasic}}==
Returns a character string if a key is pressed during the call of Inkey(). It doesn't interrupt (halt) the program flow.
Returns a character string if a key is pressed during the call of Inkey(). It doesn't interrupt (halt) the program flow.

Revision as of 11:01, 9 October 2010

Keyboard input/Keypress check is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Determine if a key has been pressed and store this in a variable. If no key has been pressed, the program should continue without waiting.

BASIC

ZX Spectrum Basic

<lang basic>10 REM k$ will be empty, if no key has been pressed 20 LET k$ = INKEY$</lang>

PureBasic

Returns a character string if a key is pressed during the call of Inkey(). It doesn't interrupt (halt) the program flow.

If special keys (non-ASCII) have to be handled, RawKey() should be called after Inkey(). <lang PureBasic>k$ = Inkey()</lang>