INKEY$ returns a string containing the character for the key pressed.
Syntax:RetStr = INKEY$ Return Value:
Parameters:
|
Remarks: INKEY$ does not wait for keyboard input and does not automatically echo to the screen.
CLS PRINT "Press a key to stop TIME$." WHILE INKEY$ = "" LOCATE 2, 1, 0 PRINT TIME$ WEND
INKEY returns a value corresponding to the key combination pressed.
👉 Because the INKEY function uses device-dependent values generated by the keyboard hardware/software for return of some of the key presses, consistent values cannot be assured across various hardware/software configurations.
Also, on some systems, because mouse and keyboard handlers are tied together in Windows, INKEY will return values when the mouse is moving over an active window.
Syntax:RetVal = INKEY Return Value:
|
👉 Unlike INKEY$, INKEY does wait for keyboard input but does not automatically echo to the screen.
See the KEYPRESS for another BCX function that waits for keyboard input.
Use the following program to determine which number is generated by
DIM a% CLS PRINT "Press keys to see their key codes." PRINT "Press Esc to quit" WHILE a% <> 27 a% = INKEY IF a% <> 0 THEN LOCATE 3, 4 PRINT " " LOCATE 3, 4 PRINT a% END IF WEND
DIM A% RANDOMIZE(TIMER) CLS DO LOCATE 1,1 PRINT "Press Esc or Enter"; PRINT RND LOCATE 1, 30 A% = INKEY IF A% = 27 THEN LOCATE 2, 1 PRINT "This arbitrary randomness must end !" EXIT DO END IF IF A% = 13 THEN LOCATE 2, 1 PRINT "Jumping into DaSub" CALL DaSub() END IF LOOP PRINT "You are no longer in the loop." SUB DaSub () STATIC Cnt% Cnt% = Cnt% + 1 PRINT "Added one more to the pile" PRINT "Pile is now " & STR$(Cnt%) END SUB
LCLICK returns TRUE, if the left mouse button has been pressed; FALSE, if the left mouse button has not been pressed.
Syntax:RetVal = LCLICK Return Value:
Parameters:
|
LCLICK is SWAPBUTTON aware.
Here is a simple console example. Tune your guitar!
WHILE NOT LCLICK ' loop until a left mouse button click is detected Beep( 82.41, 1500) ' E (6th string): 82.41 Hz (E2) Beep(110.00, 1500) ' A (5th string): 110.00 Hz (A2) Beep(146.83, 1500) ' D (4th string): 146.83 Hz (D3) Beep(196.00, 1500) ' G (3rd string): 196.00 Hz (G3) Beep(246.94, 1500) ' B (2nd string): 246.94 Hz (B3) Beep(329.63, 1500) ' E (1st string): 329.63 Hz (E4) WEND
RCLICK returns TRUE, if the right mouse button has been pressed; FALSE, if the right mouse button has not been pressed.
Syntax:RetVal = RCLICK Return Value:
Parameters:
|
RCLICK is SWAPBUTTON aware.