Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

keybd_event (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for keybd_event in other DLLs exists, click on Find References to the right.

.
Summary
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 msdn.microsoft.com)

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:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

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);
    }
    }

Documentation
keybd_event on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions