User Tools

Site Tools


disabling_20_27sticky_20key_27_20action_20of_20shift

Disabling 'sticky key' action of Shift

by Richard Russell, October 2008

By default, pressing the Shift key five times activates the Windows StickyKeys accessibility feature. Whilst this can be useful for people with certain disabilities, it can be irritating if you use BBC BASIC's VDU 14 paged mode, in which scrolling is paused until the Shift key is pressed.

Although you can disable StickyKeys in Windows Control Panel, it may not be convenient to do so, and it isn't very user-friendly. A better approach may be to disable the specific action of the Shift key using the code below:

        SPI_GETSTICKYKEYS = 58
        SPI_SETSTICKYKEYS = 59
        SKF_HOTKEYACTIVE = 4
 
        DIM sk{cbSize%, dwFlags%}
        sk.cbSize% = DIM(sk{})
 
        SYS "SystemParametersInfo", SPI_GETSTICKYKEYS, DIM(sk{}), sk{}, 0
        sk.dwFlags% AND= NOT SKF_HOTKEYACTIVE
        SYS "SystemParametersInfo", SPI_SETSTICKYKEYS, DIM(sk{}), sk{}, 0

This will disable the Sticky Key action of the Shift key for the remainder of the session. You can make the change permanent by altering the final parameter from 0 to 1, but you probably won't want to do that.

If you prefer, you can restore the previous setting before your program exits as follows:

        SPI_GETSTICKYKEYS = 58
        SPI_SETSTICKYKEYS = 59
        SKF_HOTKEYACTIVE = 4
 
        DIM sk{cbSize%, dwFlags%}
        sk.cbSize% = DIM(sk{})
 
        SYS "SystemParametersInfo", SPI_GETSTICKYKEYS, DIM(sk{}), sk{}, 0
        OldStickyFlags% = sk.dwFlags%
 
        sk.dwFlags% AND= NOT SKF_HOTKEYACTIVE
        SYS "SystemParametersInfo", SPI_SETSTICKYKEYS, DIM(sk{}), sk{}, 0
 
        REM. Your program does its stuff here
 
        sk.dwFlags% = OldStickyFlags%
        SYS "SystemParametersInfo", SPI_SETSTICKYKEYS, DIM(sk{}), sk{}, 0
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
disabling_20_27sticky_20key_27_20action_20of_20shift.txt · Last modified: 2018/04/16 11:50 by richardrussell