Windows API Reference: Input

This section provides documentation for Windows API functions related to handling user input, including keyboard, mouse, and touch input.

Core Input Functions

GetKeyState

Retrieves the status of a specified key on the keyboard.

SHORT GetKeyState( int nVirtKey );

Parameters:

Return Value:

The return value specifies the status of the specified virtual key, as well as the status of the assembler for each of the controls keys. If the most significant bit of the return value is set, the key is down; otherwise, the key is up.

This function retrieves the status of a keyboard message that has already been placed in the calling thread's message queue.

SetCursorPos

Moves the cursor to the specified position on the screen.

BOOL SetCursorPos( int X, int Y );

Parameters:

Return Value:

Nonzero if successful; otherwise, zero.

GetMouseButtonsState

Retrieves the current state of the mouse buttons.

DWORD GetMouseButtonsState();

Return Value:

A bitmask indicating which mouse buttons are pressed. Possible values include:

Advanced Input Mechanisms

RegisterTouchWindow

Registers a window for touch input.

BOOL RegisterTouchWindow( HWND hwnd, ULONG ulFlags );

Parameters:

Return Value:

TRUE if the function succeeds; otherwise, FALSE.

This function is essential for enabling multi-touch support on a window.

GetRawInputDeviceInfo

Retrieves information about the specified raw input device.

UINT GetRawInputDeviceInfo( HANDLE hDevice, UINT uiCommand, LPVOID pData );

Parameters:

Related Concepts

Proper handling of user input is critical for creating responsive and user-friendly Windows applications. Always consider accessibility and different input methods.