pauseKeyEvents property

bool get pauseKeyEvents

When true, delivery of key events will be suspended.

When this property is set to true, the system generates KeyUp events for all keys currently being held, as if the user has released them. Conversely, when this property is switched back to false, and the user was holding some keys at the time, the system will generate KeyDown events as if the user just started pressing those buttons.

Implementation

bool get pauseKeyEvents => _pause;
set pauseKeyEvents (bool value)

Implementation

set pauseKeyEvents(bool value) {
  if (value == _pause) {
    return;
  }
  _pause = value;
  final timeStamp = ServicesBinding.instance.currentSystemFrameTimeStamp;
  for (final physicalKey in _physicalKeys) {
    final logicalKey = HardwareKeyboard.instance.lookUpLayout(physicalKey)!;
    onKeyEvent(
      (_pause ? KeyUpEvent.new : KeyDownEvent.new)(
        physicalKey: physicalKey,
        logicalKey: logicalKey,
        timeStamp: timeStamp,
        synthesized: true,
      ),
    );
  }
}