Skip to content

Conversation

@gspencergoog
Copy link
Contributor

Description

Currently, we listen to keyboard events to find out which keys should be represented in RawKeyboard.instance.keysPressed, but that's not sufficient to represent the physical state of the keys, since modifier keys could have been pressed when the overall app did not have keyboard focus (especially on desktop platforms).

This PR synchronizes the list of modifier keys in keysPressed with the modifier key flags that are present in the raw key event so that they can be relied upon to represent the current state of the keyboard. When synchronizing these states, we don't send any new key events, since they didn't happen when the app had keyboard focus, but if you ask "is this key down", we'll give the right answer.

Related Issues

Fixes #40496

Tests

  • Added tests for each of the platforms we support.
  • Modified the event simulation code in flutter_test so that the raw event data could be obtained, and wrapped it in a namespace class called KeyEventSimulator.

Breaking Change

  • No, this is not a breaking change.

@gspencergoog gspencergoog added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. a: desktop Running on desktop labels Nov 1, 2019
@gspencergoog gspencergoog force-pushed the modifier_sync branch 4 times, most recently from e96e3a3 to 28620e3 Compare November 6, 2019 03:20
Copy link
Contributor

@franciscojma86 franciscojma86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo avoiding "we" in comments

@gspencergoog
Copy link
Contributor Author

Thanks! Don't worry, we'll fix that. :-)

@gspencergoog gspencergoog merged commit 028ed71 into flutter:master Nov 6, 2019
@gspencergoog gspencergoog deleted the modifier_sync branch November 13, 2019 23:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: desktop Running on desktop a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RawKeyboard has stuck pressed keys when shift is released — shortcuts fail as a result

3 participants