Page 1 of 1

Testing capslock with getModifierState('CapsLock')

Posted: Mon Jun 20, 2022 7:57 am
by laura

Hi,

I am trying to test a capslock indicator with Siesta by this code:

t.chain({
            type: '[CAPS]'
        }, {
            type: 'test',
            target: passwordfield
        })

The KeyboardEvent I get on running the test indeed contains the getModifierState function, which unfortunately does not return the correct value for getModifierState('CapsLock').
As this might be one of the main use cases for the caps keycode, is there any solution or workaround for this?

Regards,
Laura


Re: Testing capslock with getModifierState('CapsLock')

Posted: Mon Jun 20, 2022 10:03 am
by nickolay

Hello,

Unfortunately, for synthetic events switching the state of the CAPSLOCK button is not possible. You can however simulate the "SHIFT" key pressing with options config:

t.chain(
    { type : 'test', target : 't', options : { shiftKey : true } }
)