Difference between revisions of "INKEY()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Class==
 
Keyboard Events
 
 
 
 
==Purpose==
 
==Purpose==
 
Function to return key press
 
Function to return key press
Line 12: Line 8:
  
 
==See Also==
 
==See Also==
[[CHR()]], [[INPUT]], [[LASTKEY()]], [[MCOL()]], [[MESSAGE]], [[MROW()]], [[ON ESCAPE]], [[ON KEY]], [[ON MOUSE]], [[READKEY()]], [[SET INKEYDELAY]], [[SET KEY]], [[SET MESSAGE]], [[SET PCKEYS]], [[SLEEP]], [[WAIT]]
+
[[CHR()]], [[INPUT]], [[LASTKEY()]], [[MCOL()]], [[MESSAGE]], [[MROW()]], [[ON ESCAPE]], [[ON KEY]], [[ON MOUSE]], [[READKEY()]], [[SET INKEYDELAY]], [[SET KEY]], [[SET MESSAGE]], [[SET PCKEYS]], [[SET TYPEAHEAD]], [[SLEEP]], [[WAIT]]
  
  
Line 70: Line 66:
 
? "Press any key..."
 
? "Press any key..."
 
ch = inkey(0)
 
ch = inkey(0)
 
// Recital Mirage Example
 
? "Click to continue..."
 
mouse_op = inkey(0,"M")
 
if mouse_op = 151
 
    // left click
 
    //...
 
elseif mouse_op = 152
 
    //right click
 
    //...
 
endif
 
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Mirage Server, Recital Terminal Developer
+
Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Keyboard Events]]
 
[[Category:Keyboard Events]]
 
[[Category:Keyboard Events Functions]]
 
[[Category:Keyboard Events Functions]]

Latest revision as of 15:51, 24 November 2014

Purpose

Function to return key press


Syntax

INKEY([<expN>[,<expC>]])


See Also

CHR(), INPUT, LASTKEY(), MCOL(), MESSAGE, MROW(), ON ESCAPE, ON KEY, ON MOUSE, READKEY(), SET INKEYDELAY, SET KEY, SET MESSAGE, SET PCKEYS, SET TYPEAHEAD, SLEEP, WAIT


Description

The INKEY() function returns zero if no key has been pressed on the keyboard, or a non-zero value which is the ASCII code for the key if one has been pressed.

<expN>

If the optional parameter <expN> is included then the INKEY() function will wait <expN> number of seconds for a key to be pressed. If no key is pressed during that time, the program will continue to execute and INKEY() will return a value of 0. If a key is pressed during the specified time, the program will continue to execute and INKEY() will return the ASCII code for the key pressed.

If the value of zero is specified for <expN>, then the INKEY() function will wait until a key is pressed on the keyboard. The command SET PCKEYS is used to change the return value of the INKEY() function. If it is set ON, then the return value will match an IBM PC keyboard. If INKEYDELAY is set OFF, then DO WHILE loops that wait for user input with the INKEY() function may be very CPU intensive. The SET INKEYDELAY command controls the wait period for the INKEY() function.

<expC>

A second parameter, <expC> is available in Recital Mirage. If <expC> is equal to "M", the INKEY() function will trap and return mouse clicks. The numeric value returned indicates the mouse operation.


INKEY() Return Value Mouse Operation
151 LEFTCLICK
152 RIGHTCLICK
153 DBLCLICK
154 CTRL+LEFTCLICK
155 CTRL+RIGHTCLICK
156 CTRL+DBLCLICK
157 SHIFT+LEFTCLICK
158 SHIFT+RIGHTCLICK
159 SHIFT+DBLCLICK
160 ALT+LEFTCLICK
161 ALT+RIGHTCLICK
162 ALT+DBLCLICK


INKEY(<expN>,"M") can also be used in conjunction with the ON MOUSE command to run a command when a mouse operation takes place. The command run can be a call to a procedure or User Defined Function if required. The MROW() and MCOL() functions can be called to determine the current row and column positions at the time of the mouse operation. The LASTKEY() function can be called to determine the type of operation. LASTKEY() returns the same numeric values for mouse operations as shown in the table above.


Example

do while inkey()=0
    @0,68 say ampm()
    sleep 2
enddo
 
// Another Example
? "Press any key..."
ch = inkey(0)


Products

Recital