Syntax

Parameters

A virtual-key code. The code must be a value in the range 1 to 254. For a complete list, see Virtual Key Codes.

bScan [in]

Type: BYTE

A hardware scan code for the key.

dwFlags [in]

Type: DWORD

Controls various aspects of function operation. This parameter can be one or more of the following values.

Value

Meaning

KEYEVENTF_EXTENDEDKEY

0x0001

If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).

KEYEVENTF_KEYUP

0x0002

If specified, the key is being released. If not specified, the key is being depressed.

dwExtraInfo [in]

Type: ULONG_PTR

An additional value associated with the key stroke.

Return value

This function does not return a value.

Remarks

An application can simulate a press of the PRINTSCRN 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.

Examples

The following sample program toggles the NUM LOCK light by using keybd_event with a virtual key of VK_NUMLOCK. It takes a Boolean value that indicates whether the light should be turned off (FALSE) or on (TRUE). The same technique can be used for the CAPS LOCK key (VK_CAPITAL) and the SCROLL LOCK key (VK_SCROLL).