Pass the injected flag to the decide_handleRawKey extension point - #20748
Open
LeonarddeR wants to merge 1 commit into
Open
Pass the injected flag to the decide_handleRawKey extension point#20748LeonarddeR wants to merge 1 commit into
LeonarddeR wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends NVDA’s raw keyboard veto extension point to include whether the underlying low-level hook flagged an event as software-injected, enabling add-ons to precisely filter injected key echoes (e.g., in full-screen Remote Desktop scenarios) while remaining backward compatible for existing handlers.
Changes:
- Forward the low-level hook’s
injectedflag throughkeyboardHandler.internal_keyDownEvent/internal_keyUpEventintoinputCore.decide_handleRawKey.decide(...). - Document the new
injectedkwarg forinputCore.decide_handleRawKey, and add type annotations/docstrings to the hook callbacks. - Add a developer changelog entry describing the new kwarg and compatibility guidance for handlers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| user_docs/en/changes.md | Documents the new injected kwarg for the decide_handleRawKey extension point and notes backward-compatible handler signatures. |
| source/keyboardHandler.py | Forwards injected into decide_handleRawKey and adds annotations/docstrings to the hook callbacks. |
| source/inputCore.py | Updates decide_handleRawKey extension point documentation to include the injected kwarg. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
215
to
221
| if not inputCore.decide_handleRawKey.decide( | ||
| vkCode=vkCode, | ||
| scanCode=scanCode, | ||
| extended=extended, | ||
| pressed=True, | ||
| injected=injected, | ||
| ): |
Add type annotations and docstrings to keyboardHandler.internal_keyDownEvent and internal_keyUpEvent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Closes #20714
Summary of the issue:
NVDA's low level keyboard hook knows whether a key event was injected. However, the extension point that lets code veto a raw key event only passes
vkCode,scanCode,extendedandpressedto its handlers.injectedis missing.Description of user facing changes:
None.
Description of developer facing changes:
Handlers of
inputCore.decide_handleRawKeynow also receiveinjected.It is
Truewhen the key event was injected by software rather than generated by the keyboard.The two hook callbacks in
keyboardHandler,internal_keyDownEventandinternal_keyUpEvent, gained type annotations and docstrings.Description of development approach:
The low level keyboard hook already passes the injected flag to
keyboardHandler.internal_keyDownEventandinternal_keyUpEvent.Both functions now forward it to
decide_handleRawKey.decideas theinjectedkeyword argument.Extension point handlers only receive the keyword arguments they declare, so existing handlers keep working unchanged.
A handler that must also run on older NVDA versions can declare the parameter with a default, such as
injected: bool | None = None.Testing strategy:
Manual, with caps lock set as NVDA modifier key on both ends of a full screen mstsc session and an add-on handler on
decide_handleRawKeythat logsinjected:The echoed caps lock events arrive with
injected=True; the keys forwarded to the server never reach the client's hook.Falsefor injected caps lock events stops the local caps lock from toggling.Known issues with pull request:
None.
Code Review Checklist: