keybd_event (coredll)
Last changed: -

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 (from

C# Signature:

[DllImport("coredll.dll", EntryPoint="keybd_event", SetLastError=true)]
internal static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

VB Signature:

Declare Sub keybd_event Lib "coredll.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!


Taken from openNetCF in OpenNETCF.Win32.Core

Tips & Tricks:

Please add some!

Sample Code:

//This sample code is mainly used to turn the backlight on a WM device. The keystrokes can changed to use for other functions

    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;

    namespace Win32
    public static class CoreDLL
        [DllImport("coredll.dll", EntryPoint = "keybd_event", SetLastError = true)]
        public static extern void keybd_event
        byte bVk,
        byte bScan,
        int dwFlags,
        int dwExtraInfo

        //To call the key stroke to turn on the Backlight.
        keybd_event(01, 01, 1, 1);

keybd_event on MSDN