please dont rip this site Prev Next

keybd_event info  Overview  Group

The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driverís interrupt handler calls the keybd_event function.

Windows NT only: This function has been superseded. Use SendInput instead.

VOID keybd_event(

    BYTE bVk,

// virtual-key code

    BYTE bScan,

// hardware scan code

    DWORD dwFlags,

// flags specifying various function options

    DWORD dwExtraInfo 

// additional data associated with keystroke



Specifies a virtual-key code. The code must be a value in the range 1 to 254.
Specifies a hardware scan code for the key.
A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags:




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


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

Specifies an additional 32-bit value associated with the key stroke.

Return Values

This function has no return value.


Although keybd_event passes an OEM-dependent hardware scan code to Windows, applications should not use the scan code. Windows 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 Windows 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.

See Also

GetAsyncKeyState, GetKeyState, MapVirtualKey, SetKeyboardState

file: /Techref/os/win/api/win32/func/src/f52_20.htm, 4KB, , updated: 2000/4/7 12:19, local time: 2023/6/1 18:21,

 ©2023 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> keybd_event</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2023 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!