SetKeyboardState function (Windows)

Switch View :
ScriptFree
SetKeyboardState function

Applies to: desktop apps only

Copies an array of keyboard key states into the calling thread's keyboard input-state table. This is the same table accessed by the GetKeyboardState and GetKeyState functions. Changes made to this table do not affect keyboard input to any other thread.

Syntax

BOOL WINAPI SetKeyboardState(
  __in  LPBYTE lpKeyState
);

Parameters

lpKeyState [in]

Type: LPBYTE

A pointer to a 256-byte array that contains keyboard key states.

Return value

Type: BOOL

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Because the SetKeyboardState function alters the input state of the calling thread and not the global input state of the system, an application cannot use SetKeyboardState to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK (or the Japanese KANA) indicator lights on the keyboard. These can be set or cleared using SendInput to simulate keystrokes.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
GetAsyncKeyState
GetKeyboardState
GetKeyState
keybd_event
MapVirtualKey
SendInput
Conceptual
Keyboard Input

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Content

ziya orkun
user32.dll
user32.dll