Keyboard input/Keypress check: Difference between revisions

Keyboard input/Keypress check in various BASIC dialents (BASIC256, QBasic and Yabasic)
No edit summary
(Keyboard input/Keypress check in various BASIC dialents (BASIC256, QBasic and Yabasic))
Line 504:
 
=={{header|BASIC}}==
 
==={{header|BBCApplesoft BASIC}}===
<lang ApplesoftBasic>K = PEEK(-16384) : IF K > 127 THEN POKE -16368,0 : K$ = CHR$(K)</lang>
 
==={{header|BaCon}}===
Line 513 ⟶ 516:
END IF</lang>
 
==={{header|Applesoft BASICBASIC256}}===
<lang freebasic>do
<lang ApplesoftBasic>K = PEEK(-16384) : IF K > 127 THEN POKE -16368,0 : K$ = CHR$(K)</lang>
k$ = key
until k$ <> ""
 
if length(k$) = 2 then
print "The key pressed was "; k$; " (ascii "; chr(k$); ")"
else
print "An extended key was pressed"
end if</lang>
 
==={{header|BBC BASIC}}===
<lang bbcbasic> key$ = INKEY$(0)</lang>
If there was no keypress an empty string is returned. Alternatively a numeric key-code may be obtained; if there was no keypress -1 is returned:
<lang bbcbasic> key% = INKEY(0)</lang>
 
==={{header|IS-BASIC}}===
Line 522 ⟶ 538:
 
<lang IS-BASIC>100 GET K$</lang>
 
==={{header|QBasic}}===
<lang QBasic>DO: k$ = INKEY$: LOOP UNTIL k$ <> ""
PRINT k$</lang>
 
==={{header|Yabasic}}===
<code>inkey$</code> interrupts (halt) the flow of the program until a key is pressed.
 
<code>inkey$</code> may only be used, if <code>clear screen</code> has been called at least once.
<lang yabasic>clear screen
k$ = inkey$</lang>
 
==={{header|ZX Spectrum Basic}}===
Line 529 ⟶ 556:
20 LET k$ = INKEY$</lang>
 
==={{header|BBC BASIC}}===
<lang bbcbasic> key$ = INKEY$(0)</lang>
If there was no keypress an empty string is returned. Alternatively a numeric key-code may be obtained; if there was no keypress -1 is returned:
<lang bbcbasic> key% = INKEY(0)</lang>
 
=={{header|C}}==
2,122

edits