handleKeyEvent method Null safety
- KeyEvent event
Process a new KeyEvent by recording the state changes and dispatching to handlers.
Implementation
bool handleKeyEvent(KeyEvent event) {
_assertEventIsRegular(event);
final PhysicalKeyboardKey physicalKey = event.physicalKey;
final LogicalKeyboardKey logicalKey = event.logicalKey;
if (event is KeyDownEvent) {
_pressedKeys[physicalKey] = logicalKey;
final KeyboardLockMode? lockMode = KeyboardLockMode.findLockByLogicalKey(event.logicalKey);
if (lockMode != null) {
if (_lockModes.contains(lockMode)) {
_lockModes.remove(lockMode);
} else {
_lockModes.add(lockMode);
}
}
} else if (event is KeyUpEvent) {
_pressedKeys.remove(physicalKey);
} else if (event is KeyRepeatEvent) {
// Empty
}
return _dispatchKeyEvent(event);
}