physicalKey property Null safety

PhysicalKeyboardKey physicalKey
override

Returns an object representing the physical location of this key on a QWERTY keyboard.

The PhysicalKeyboardKey ignores the key map, modifier keys (like SHIFT), and the label on the key. It describes the location of the key as if it were on a QWERTY keyboard regardless of the keyboard mapping in effect.

PhysicalKeyboardKeys are used to describe and test for keys in a particular location.

For instance, if you wanted to make a game where the key to the right of the CAPS LOCK key made the player move left, you would be comparing the result of this physicalKey with PhysicalKeyboardKey.keyA, since that is the key next to the CAPS LOCK key on a QWERTY keyboard. This would return the same thing even on a French keyboard where the key next to the CAPS LOCK produces a "Q" when pressed.

If you want to make your app respond to a key with a particular character on it regardless of location of the key, use RawKeyEvent.logicalKey instead.

See also:

Implementation

@override
PhysicalKeyboardKey get physicalKey => kWindowsToPhysicalKey[scanCode] ?? PhysicalKeyboardKey(LogicalKeyboardKey.windowsPlane + scanCode);