CONSOLEINPUT: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
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]]'''
* '''[[Keywords currently not supported by QB64#Keywords not supported in Linux or macOS versions|Keyword not supported in Linux or macOS versions]]'''




{{PageExamples}}
{{PageExamples}}
''Example 1:'' Reading individual key strokes from a console window (Windows).
''Example 1:'' Reading individual key strokes from a console window (Windows).
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$CONSOLE}}:ONLY
{{Cl|$CONSOLE}}:ONLY
{{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}}
{{Cl|_DEST}} {{Cl|_CONSOLE}}: {{Cl|_SOURCE}} {{Cl|_CONSOLE}}

Revision as of 01:18, 23 January 2023

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


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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link