CINP: 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 Tag: Undo |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
* Return values are the same as the ones for [[INP]] when used to read keyboard input. See table below. | * Return values are the same as the ones for [[INP]] when used to read keyboard input. See table below. | ||
* Negative values returned indicate that a key was released or a lock function key has been turned off. | * Negative values returned indicate that a key was released or a lock function key has been turned off. | ||
* '''[[ | * '''[[Keywords currently not supported by QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux or macOS versions]]''' | ||
{{ | {{FixedStart}}' '''Extended Keyboard Press Scancodes''' | ||
' | ' | ||
'''' | ' '''Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause''' | ||
' | ' 1 59 60 61 62 63 64 65 66 67 68 87 88 0 70 29 | ||
' | ' '''`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -''' | ||
' | ' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 82 71 73 69 53 55 74 | ||
' | ' '''Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + ''' | ||
' | ' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 71 72 73 78 | ||
' | ' '''CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E''' | ||
' | ' 58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77 '''n''' | ||
' | ' '''Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t''' | ||
' | ' 42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 '''e''' | ||
' | ' '''Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r''' | ||
' | ' 29 {{Text|91|purple}} 56 57 56 {{Text|92 93|purple}} 29 75 80 77 82 83 28 | ||
' | ' | ||
{{ | {{FixedEnd}} | ||
{{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 54: | Line 67: | ||
* [[_CONSOLEINPUT]] | * [[_CONSOLEINPUT]] | ||
* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] | * [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 17:58, 6 October 2024
The _CINP function returns keyboard key press codes from a $CONSOLE window. Windows-only.
Syntax
- keycode& = _CINP
Description
- Return values are the same as the ones for INP when used to read keyboard input. See table below.
- Negative values returned indicate that a key was released or a lock function key has been turned off.
- Keyword not supported in Linux or macOS versions
' Extended Keyboard Press Scancodes ' ' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause ' 1 59 60 61 62 63 64 65 66 67 68 87 88 0 70 29 ' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * - ' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 82 71 73 69 53 55 74 ' Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + ' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 71 72 73 78 ' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E ' 58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77 n ' Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t ' 42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 e ' Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r ' 29 91 56 57 56 92 93 29 75 80 77 82 83 28 ' |
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