Skip to content

Improve keyboardHandler.KeyboardInputGesture.fromName to accept keys in indeterminate order #8201

@LeonarddeR

Description

@LeonarddeR

Steps to reproduce:

Type the following into a python console:

import keyboardHandler
gesture = keyboardHandler.KeyboardInputGesture.fromName("alt+b+control")
print(gesture.identifiers)

Expected behavior:

(u'kb(laptop):alt+b+control', u'kb:alt+b+control')

Actual behavior:

(u'kb(laptop):alt++control', u'kb:alt++control')

Technical background

When creating an input gesture from a key name (e.g. when emulating gestures), NVDA treats the last key in the sequence as the main key and the other keys as modifiers. KeyboardInputGesture.fromName is used by scriptHandler._makeKbEmulateScript to emulate gestures. However, while in gestures the key order may be indeterminate, this may not the case when creating input gestures from a key name.

Proposed fix

Rather than taking the last key in the input sequence (e.g. control in alt+b+control) as the main key, a non modifier should always be the main key, except for cases where only modifiers are provided. This means that in the alt+b+control example, b should be the main key. the fromName function should also raise a ValueError in cases where multiple main keys are provided (e.g. control+b+c).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions