Repository navigation
feat: Introduce KeyboardCallbacks to new event system - #4114
Open
luanpotter wants to merge 1 commit into
Open
luanpotter wants to merge 1 commit into
luanpotter wants to merge 1 commit into
Conversation
luanpotter
force-pushed
the
luan.new-keyboard-callbacks
branch
from
October 11, 2026 21:03
40885b6 to
0890b1a
Compare
luanpotter
marked this pull request as ready for review
October 11, 2026 21:11
This branch has not been deployed
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.
Description
Introduce
KeyboardCallbacksto new event system.Adds a keyboard input layer to the new event system, as per our master plan.
It allows components (and games) to receive
KeyPressEvent,KeyHoldEventandKeyReleaseEventthroughonKeyPress,onKeyHoldandonKeyRelease. To handle all three in one function, overrideonKeyboardEvent.All three events extend a sealed
KeyboardEvent. It carries thelogicalKey,physicalKey, the set of keys held at the time, therawevent, and helpers for modifier keys (isShiftPressed,isControlPressed,isAltPressed,isMetaPressed), and lock mode helpers (isCapsLockOn,isNumLockOn,isScrollLockOn).characterexists only on press and hold events, since Flutter never provides one on release.Keyboard events have no position, so they go to every listening component (topmost first) unless one sets
continuePropagation = false. This is different than taps that default totrue, but the same way scrolls, hovers, drags, and some others do.Events arrive through the
GameWidgetexisting Focus, via a newkeyDetectorhook onGame. This is purely additive:KeyboardEvents,KeyboardHandlerandHardwareKeyboardDetectorare untouched for now and work alongside it. I will followup with supporting hardware detection mode on the game level, so component-level callers can use a unified interface, regardless of "focus mode".Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?