getLogicalKeyForPhysicalKey method

LogicalKeyboardKey? getLogicalKeyForPhysicalKey(
  1. PhysicalKeyboardKey physicalKey, {
  2. bool shift = false,
  3. bool alt = false,
  4. bool meta = false,
})

Returns the LogicalKeyboardKey for given PhysicalKeyboardKey and modifiers for this keyboard layout or null if it could not have been determined.

Implementation

LogicalKeyboardKey? getLogicalKeyForPhysicalKey(
  PhysicalKeyboardKey physicalKey, {
  bool shift = false,
  bool alt = false,
  bool meta = false,
}) {
  final key = _physicalToKey[physicalKey.usbHidUsage];

  if (key == null) {
    return null;
  }

  if (meta && key.logicalMeta != null) {
    return LogicalKeyboardKey(key.logicalMeta!);
  } else if (shift && alt && key.logicalAltShift != null) {
    return LogicalKeyboardKey(key.logicalAltShift!);
  } else if (shift && !alt && key.logicalShift != null) {
    return LogicalKeyboardKey(key.logicalShift!);
  } else if (!shift && alt && key.logicalAlt != null) {
    return LogicalKeyboardKey(key.logicalAlt!);
  } else if (!shift && !alt && key.logical != null) {
    return LogicalKeyboardKey(key.logical!);
  } else {
    return null;
  }
}