Keyboard input/Keypress check: Difference between revisions

m
Use inputReady instead of the deprecated function keypress
m (syntax highlighting fixup automation)
m (Use inputReady instead of the deprecated function keypress)
 
(5 intermediate revisions by 3 users not shown)
Line 796:
The key pressed was A (ascii 65)
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_window = 1
 
void local fn BuildWindow
subclass window _window, @"Keyboard input/Keypress check"
text,24
print %(180,190)@"Press any key"
end fn
 
void local fn DoDialog( ev as long, tag as long )
select ( ev )
case _windowKeyDown
select ( tag )
case _window
cls : printf %(180,190)@"\"%@\" key pressed",fn EventCharacters
DialogEventSetBool( YES )// we handled
end select
end select
end fn
 
fn BuildWindow
 
on dialog fn DoDialog
 
HandleEvents
</syntaxhighlight>
 
=={{header|Gambas}}==
Line 1,356 ⟶ 1,384:
goto "#return"
</syntaxhighlight>
 
=={{header|RPL}}==
≪ '''IF''' KEY '''THEN''' 'Entry' STO '''END''' ≫
If no key is pressed and the <code>Entry</code> variable does not exist yet, it won't be created.
 
=={{header|Ruby}}==
Line 1,412 ⟶ 1,444:
The library [http://seed7.sourceforge.net/libraries/keybd.htm keybd.s7i] defines
the file [http://seed7.sourceforge.net/libraries/keybd.htm#KEYBOARD KEYBOARD] and
the function [http://seed7.sourceforge.net/libraries/keybd.htm#keypressed%28in_keyboard_file%29inputReady(in_console_keybd_file) keypressedinputReady],
which can be used to determine if a key has been pressed.
<syntaxhighlight lang="seed7">if keypressedinputReady(KEYBOARD) then
writeln("A key was pressed");
else
Line 1,462 ⟶ 1,494:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">import "scheduler" for Scheduler
import "timer" for Timer
import "io" for Stdin, Stdout
28

edits