. DirectXtras Home
        Home

DirectCommunication Xtra
DirectConnection Xtra
DirectControl Xtra
DirectEmail Xtra
DirectFTP Xtra
DirectImage Xtra
DirectInteraction Xtra
DirectOS Xtra
Documentation
License Agreement
Licensing Fees
Order Form
DirectSMS Xtra
DirectSound Xtra
DirectTransition Xtra
DirectTransition3D Xtra Set I
DirectTransition3D Xtra Set II
DirectTransition3D Xtra Set III
DirectTTS Xtra
XtrAgent
DirectXport Xtra

SpeechPlugin

Special Discounted Bundles

The Gallery
How To Order
Order Form
Check for Upgrades

Sign in
Change Your Profile

Contact Us
















    .
DirectXtras
Xtra Power for Director & Authorware



DirectOS Xtra
 Directing Windows and MacOS. The OS at your fingertips!

Authorware 4.x Compatible Authorware 5.x CompatibleAuthorware 6.x CompatibleAuthorware 7.x CompatibleDirector 5.x Compatible Director 6.x CompatibleDirector 7.x Compatible Director 8.x CompatibleDirector MX Compatible     MacOS 8.x and 9.x CompatibleMacOS X CompatibleWindows Compatible   

dosKeyPress(integer keyCode, integer KeyState)

Synthesizes a keystroke on the active window. Applications can use such a synthesized keystroke to generate key down and key up events. To direct a keystroke to a specific window, first set it to the active window using the dosSetFrontWindow() function.

Parameters :

keyCode : An integer specifying the virtual key code of the key to depress or release. Please refer to dosGetKeyState() function for possible values. On MacOS classic, the specified key can not be Control, Alt, Shift, Caps Lock or the Command Key. These modifier keys can be Synthesized on MacOS classic using the KeyState parameter. On Windows and MacOS X, the specified key can be any key.
KeyState : Pass 1 to depress the key and 0 to release it. In addition, one or more of the following numbers can be added to this parameter in order to synthesize special modifier keystrokes along with the key specified by keyCode:

2 - Control
4 - Alt
8- Shift
16 - Caps Lock on
32 - Command Key (MacOS) \ Windows Key (Windows)

For example,  to synthesize Control + Alt + 7 keystroke, call:

dosKeyPress (55, 1+2+4)
 

If this parameter is used to depress one or more of the above modifier keys, the function will also release the modifier key(s) after depressing the key specified by keyCode. If Caps Lock is specified in this parameter, the function will generate the key while the Caps Lock key is toggled on, then set the Caps Lock key back to its original state. The key specified by the keyCode parameter will not be released. Applications can release it by calling this function again with the KeyState parameter sets to zero.

Return Value : An integer indicating whether the method was successful or not. If 1 is returned, the method was successful. If 0 is returned, the method was not successful in which case dosGetLastError() should be called to determine the cause of the error. 

Remarks :

The behavior of this function slightly differ on MacOS classic.

On Windows and MacOS X, the function generates a keystroke as if the physical keyboard key was actually pressed. For example, setting the keyCode parameter to 20 and the keyState parameter to 1 will actually toggle the Caps Lock key and change the status of the Caps Lock key led. As a result, after the function depresses a key, dosGetKeyState() will report that the key is pressed (even though physically it is not) until the user physically releases the key or the function is called again to release the key.

On MacOS classic, the function sends a key down or key up event to the active application. It does not change the status of the physical keyboard keys and therefore after the function depresses a key, dosGetKeyState() will not report that the synthesized keys are pressed unless they are physically pressed by the user.



DirectXtras Inc.
P.O Box 2645, Menlo Park, CA, 94026, U.S.A
Voice: +1-415-5058249, Fax: +1-801-8585841
Toll Free: 1-800-4453093
E-mail General Information: info@directxtras.com
E-mail Technical Support: support@directxtras.com

Copyright 1996-2004 DirectXtras Inc. All Rights Reserved.
WebMaster: tamar@directxtras.com
Last Updated: 12/19/2002 2:21:28 AM.