- logicalKey
These represent logical keys, which are keys which are interpreted in the context of any modifiers, modes, or keyboard layouts which may be in effect.
This is contrast to PhysicalKeyboardKey, which represents a physical key in a particular location on the keyboard, without regard for the modifier state, mode, or keyboard layout.
As an example, if you wanted to implement an app where the "Q" key "quit" something, you'd want to look at the logical key to detect this, since you would > like to have it match the key with "Q" on it, instead of always looking for "the key next to the TAB key", since on a French keyboard, the key next to the > TAB key has an "A" on it.
Conversely, if you wanted a game where the key next to the CAPS LOCK (the "A" key on a QWERTY keyboard) moved the player to the left, you'd want to look
at the physical key to make sure that regardless of the character the key produces, you got the key that is in that location on the keyboard.
- physicalKey
These represent physical keys, which are keys which represent a particular key location on a QWERTY keyboard. It ignores any modifiers, modes, or keyboard layouts which may be in effect. This is contrast to LogicalKeyboardKey, which represents a logical key interpreted in the context of modifiers, modes, and/or keyboard layouts.PhysicalKeyboardKeys are used to describe and test for keys in a particular location.
As an example, if you wanted a game where the key next to the CAPS LOCK (the "A" key on a QWERTY keyboard) moved the player to the left, you'd want to look at the physical key to make sure that regardless of the character the key produces, you got the key that is in that location on the keyboard.
Conversely, if you wanted to implement an app where the "Q" key "quit" something, you'd want to look at the logical key to detect this, since you would like to have it match the key with "Q" on it, instead of always looking for "the key next to the TAB key", since on a French keyboard, the key next to the TAB key has an "A" on it.
abstract from https://api.flutter.dev/flutter/services/KeyboardKey-class.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步