Difference between revisions of "CONSOLEINPUT"

From QB64 Wiki
Jump to navigation Jump to search
imported>Odin
(Created page with "{{DISPLAYTITLE:_CONSOLEINPUT}} 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...")
 
imported>Odin
Line 15: Line 15:
  
 
{{PageExamples}}
 
{{PageExamples}}
''Example 1:'' Mouse coordinate, click and scroll events are returned sequentially inside of a _MOUSEINPUT loop.
+
''Example 1:'' Reading individual key strokes from a console window (Windows).
 
{{CodeStart}} '' ''
 
{{CodeStart}} '' ''
 
{{Cl|$CONSOLE}}:ONLY
 
{{Cl|$CONSOLE}}:ONLY

Revision as of 01:17, 9 February 2020

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.


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.
  • Not available in Linux or macOS.


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:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page