CONSOLEINPUT: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
* Must be called before reading any of the other mouse functions and before reading [[_CINP]]. | * Must be called before reading any of the other mouse functions and before reading [[_CINP]]. | ||
* To clear all previous input data, read [[_CONSOLEINPUT]] in a loop until it returns 0. | * To clear all previous input data, read [[_CONSOLEINPUT]] in a loop until it returns 0. | ||
* '''[[ | * '''[[Keywords currently not supported by QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux or macOS versions]]''' | ||
{{PageAvailability}} | |||
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | |||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''v1.4''' | |||
File:Qbpe.png|'''all''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''no''' | |||
File:Osx.png|'''no''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
{{PageExamples}} | {{PageExamples}} | ||
;Example 1: Reading individual key strokes from a console window (Windows). | |||
{{CodeStart}} | {{CodeStart}} | ||
{{ | {{Cm|$CONSOLE}}:{{Cl|ONLY}} | ||
{{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}} | {{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}} | ||
{{Cl|PRINT}} "Press any key, and I'll give you the scan code for it. <ESC> quits the demo." | {{Cl|PRINT}} {{Text|<nowiki>"Press any key, and I'll give you the scan code for it. <ESC> quits the demo."</nowiki>|#FFB100}} | ||
{{Cl|PRINT}} | {{Cl|PRINT}} | ||
{{Cl|PRINT}} | {{Cl|PRINT}} | ||
{{Cl|DO}} | {{Cl|DO}} | ||
x = {{Cl|_CONSOLEINPUT}} | x = {{Cl|_CONSOLEINPUT}} | ||
{{Cl|IF}} x = 1 {{Cl|THEN}} 'read only keyboard input ( = 1) | {{Cl|IF}} x = {{Text|1|#F580B1}} {{Cl|THEN}} {{Text|<nowiki>'read only keyboard input ( = 1)</nowiki>|#919191}} | ||
c = {{Cl|_CINP}} | c = {{Cl|_CINP}} | ||
{{Cl|PRINT}} c; | {{Cl|PRINT}} c; | ||
{{Cl|END IF}} | {{Cl|END IF}} | ||
{{Cl|LOOP}} {{ | {{Cl|DO...LOOP|LOOP UNTIL}} c = {{Text|1|#F580B1}} | ||
{{Cl|END}} | {{Cl|END}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Line 36: | Line 49: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[$CONSOLE]], [[_CONSOLE]] | * [[$CONSOLE]], [[_CONSOLE]] | ||
* [[_CINP]], [[ | * [[_CINP]], [[Keyboard scancodes#INP_Scan_Codes|Scan Codes]] | ||
* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] | * [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 17:37, 6 October 2024
The _CONSOLEINPUT function is used to monitor any new mouse or keyboard input coming from a $CONSOLE window. It must be called in order for _CINP to return valid values. Windows-only.
Syntax
- infoExists%% = _CONSOLEINPUT
Description
- Returns 1 if new keyboard information is available, 2 if mouse information is available, otherwise it returns 0.
- Must be called before reading any of the other mouse functions and before reading _CINP.
- To clear all previous input data, read _CONSOLEINPUT in a loop until it returns 0.
- Keyword not supported in Linux or macOS versions
Availability
Examples
- Example 1
- Reading individual key strokes from a console window (Windows).
$CONSOLE:ONLY _DEST _CONSOLE: _SOURCE _CONSOLE PRINT "Press any key, and I'll give you the scan code for it. <ESC> quits the demo." PRINT PRINT DO x = _CONSOLEINPUT IF x = 1 THEN 'read only keyboard input ( = 1) c = _CINP PRINT c; END IF LOOP UNTIL c = 1 END |
See also