Partager via


Enabling Sticky Keys

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The sticky keys option enables the user to type key combinations, such as CTRL+ALT+DEL, in sequence rather than simultaneously.

The user can control the settings for the sticky keys option by using the Keyboard tab of the Accessibility Control Panel application or another application for customizing the environment.

Applications use the SPI_GETSTICKYKEYS and SPI_SETSTICKYKEYS flags with the SystemParametersInfo function to get and set the sticky keys option. The STICKYKEYS structure defines the parameters for the sticky keys option. To set the sticky keys option, call SystemParametersInfo with the uiAction parameter set to SPI_SETSTICKYKEYS, the uiParam parameter set to the size of the STICKYKEYS structure, and the pvParam parameter set to a pointer to a STICKYKEYS structure that contains the sticky keys parameters that you want to use. You should set the SKF_STICKYKEYSON flag in the dwFlags member of the STICKYKEYS structure that you pass to SystemParametersInfo.

The following code example shows how to enable the sticky keys option and direct the OS to play a sound when the user latches, locks, or releases modifier keys when using the sticky keys option.

STICKYKEYS skf;
BOOL bSuccess;

// Fill in the members of the STICKYKEYS structure.

skf.cbSize = sizeof(STICKYKEYS);
skf.dwFlags = (SKF_AVAILABLE | SKF_STICKYKEYSON | SKF_AUDIBLEFEEDBACK);

// Call SystemParametersInfo with the SPI_SETSTICKYKEYS flag. 

bSuccess = SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), 
                                (LPVOID) &skf, 0); 

To retrieve information about the sticky keys option, call SystemParametersInfo with uiAction set to SPI_GETSTICKYKEYS, uiParam set to the size of the STICKYKEYS structure, and pvParam set to a pointer to a STICKYKEYS structure. Examine the values of the members of the STICKYKEYS structure after SystemParametersInfo returns to obtain the information that you want about the sticky keys option.

See Also

Concepts

Enabling Toggle Keys
Accessibility Hot Keys

Other Resources

Accessibility Application Development