keybd_event

This function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message.

VOID keybd_event( 
BYTE bVk, 
BYTE bScan, 
DWORD dwFlags, 
DWORD dwExtraInfo );

Parameters

  • bVk
    [in] Specifies a virtual-key code. The code must be a value in the range 1 to 254.

  • bScan
    [in] Specifies a hardware scan code for the key.

  • dwFlags
    [in] Specifies various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags.

    Value Description
    KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.
    KEYEVENTF_SILENT If specified, a keystroke is simulated, but no clicking sound is made.
  • dwExtraInfo
    [in] Specifies an additional 32-bit value associated with the key stroke.

Return Values

None.

Remarks

When keyboard input is disabled with EnableHardwareKeyboard(FALSE), you can simulate keyboard input using keybd_event.

Although keybd_event passes an OEM-dependent hardware scan code to the system, applications should not use the scan code. The system converts scan codes to virtual-key codes internally and clears the up/down bit in the scan code before passing it to applications.

An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h   Uibase.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

EnableHardwareKeyboard, GetAsyncKeyState, GetKeyState, MapVirtualKey

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.