Improved Input Help Mode to Report Characters Typed by Key Combinations in Normal Mode#19422
Improved Input Help Mode to Report Characters Typed by Key Combinations in Normal Mode#19422seanbudd merged 16 commits intonvaccess:masterfrom
Conversation
…, the character is reported first, followed by the key combination.
|
cc @LeonarddeR @CyrilleB79 |
|
@cary-rowen Thank you for continuing this. I don't think ToUnicodeEx modifies the keyboard state at all when the 0x04 flag is used, so if the user types a dead key in input help mode, it shouldn't affect what is typed if the user exits input help |
|
I have tested this from source but it doesn't seem to work here: Furthermore, how will the current code behave when symbol level is set to None? |
|
I have done first tests, to be continued. I can already write the following:
So still better: "majuscule+$", "Type £".
I understand that inverting the key combination and its result and adding a pause between them, you get the result later, what may be undesirable, but that's needed for clarity IMO. Alternatively, if someone really needs to explore many keys and is bothered by the time the produced character is reported, maybe a separate dry-typing feature would be more suitable. |
|
@CyrilleB79 wrote:
Wholeheartedly agree here. I think we should stick to the key sequence, a short pause, and then the character it would produce.
This suggests a restructure of the current code is necessary:
Since the current implementation doesn't work here anyway, we might need some logging here and there. Also avoid to return empty strings, rather use None to communicate that nothing is returned. |
|
@LeonarddeR Why wouldn't you use an empty string? I think always using the same datatype is a good practice. What if someone uses a function that only works with strings, and doesn't know that the function Occasionally returns None? Plus, returning an empty string is basically the same as returning nothing anyway |
It depends on the programming language and on what you're trying to communicate. For example in C#, a language I use very often, a string is a reference type and therefore can be null.
That's not applicable here. We're talking about a new property that will have a proper return annotation.
That's not true IMO. When getting a character, None tells me that there is no character to report. |
…ection - Refactor _nameForInputHelp into a list to report characters and keys as separate speech items. - Fix KeyboardInputGesture.fromName by populating scan code for character identification. - Use None for empty characters and add missing winUser constants.
# Conflicts: # user_docs/en/changes.md
There was a problem hiding this comment.
Pull request overview
This pull request enhances NVDA's input help mode to report the actual character that would be typed by a key combination, in addition to the key combination name itself. This addresses a long-standing user experience issue where pressing Shift+1 would only report "shift+1" rather than the exclamation mark "!" that would actually be typed.
Changes:
- Added character resolution capability using Windows ToUnicodeEx API with 0x04 flag to avoid modifying keyboard state
- Dead keys are now reported immediately with their character representation
- NVDA commands (containing NVDA modifier) retain their original behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| user_docs/en/changes.md | Documents the new input help mode behavior for users |
| source/winUser.py | Adds MAPVK constants needed for virtual key to scan code conversion |
| source/keyboardHandler.py | Implements character property using ToUnicodeEx API and updates _nameForInputHelp to include characters; updates fromName to calculate scanCode |
| source/inputCore.py | Adds base _nameForInputHelp property and updates _handleInputHelp to handle multiple name items with proper speech output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This point in #19422 (comment) has not been addressed:
IMO addressing it is mandatory. Point 2. has not been addressed either. You may choose not to address it, but it would be nice to hear your position on it, i.e. why do you choose to address it or not. Thanks. |
|
@cary-rowen - do you intend to continue working on this? |
|
Hi @seanbudd and @CyrilleB79 Sorry for the delay! |
# Conflicts: # user_docs/en/changes.md
|
@CyrilleB79, could you please take a quick look? I might not have reached the level you're fully satisfied with yet, but it would be great if you could just give it a simple try. Capital letters will now also be reported in a configurable way. |
|
@cary-rowen I have tested and almost all seems OK. I have tested the following cases:
With the numpad, there is an issue left, e.g. It reports 3 things instead of 2. At last, in general, there are still 2 speech logged, not only one merged. Maybe this is acceptable though. |
323cb79 to
b5bea15
Compare
|
Hi @CyrilleB79, thanks for your testing!
To correctly report uppercase letters, I've added some additional logic. It might not look very elegant at the moment, so please test it again. If the behavior is correct, we can then refine the code itself. Also, I’ve installed a French keyboard layout, but since I have no knowledge of French, it's difficult for me to test it thoroughly. |
|
@cary-rowen - can you update the PR description? @CyrilleB79 - can you confirm testing on the latest changes? |
|
I updated the PR description. |
Link to issue number:
Fixes #6621
Summary of the issue:
In input help mode, NVDA only reports the key combination name but does not report what character would be typed by that key combination in normal mode.
Description of user facing changes:
Input help mode now reports the key combination first, and then, when appropriate, the character that key combination would type in normal input mode.
Shift+1on a US keyboard will reportshift+1, then!Description of developer facing changes:
inputHelpCharacterauto property to theInputGesturebase class ininputCore.py, provided by_get_inputHelpCharacterKeyboardInputGestureinkeyboardHandler.pyusesToUnicodeExto infer the character the gesture would produce in normal input modeKeyboardInputGestureoverrides_get_inputHelpCharacterto expose that extra character to input help when appropriate_handleInputHelpnow handles the gesture display name,gesture.inputHelpCharacter, and script description separatelyDescription of development approach:
Based on the abandoned PR #15907(by @Emil-18) and #17629. The implementation uses
ToUnicodeExwith the0x04flag to get the character without modifying keyboard state. Dead key results are preserved for input help handling. Input help reports the gesture name first, and only adds the character when it provides additional information.Testing strategy:
Manual testing in input help mode with different keyboard layouts and key combinations, including printable character combinations, dead keys, command-bound gestures, and case-only differences.
Known issues with pull request:
as yet unknown
Code Review Checklist: