首页 > 其他分享 >flutter中的逻辑键和物理键(logicalKey,physicalKey)

flutter中的逻辑键和物理键(logicalKey,physicalKey)

时间:2023-01-06 10:55:22浏览次数:50  
标签:keys logicalKey logical next location key keyboard flutter physicalKey

  1. 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.

  1. 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

标签:keys,logicalKey,logical,next,location,key,keyboard,flutter,physicalKey
From: https://www.cnblogs.com/sqmw/p/17029801.html

相关文章

  • Flutter 陈航 16-主题定制 依赖管理 静态资源 三方库
    本文地址目录目录目录16|从夜间模式说起,如何定制主题?全局统一的视觉风格定制局部独立的视觉风格定制获取样式特定的值根据平台选择主题17|依赖管理:图片、配置和字体......
  • 适合编程初学者的开源项目:小游戏2048(Flutter版)
    目标为编程初学者打造入门学习项目,使用各种主流编程语言来实现。2048游戏规则一共16个单元格,初始时由2或者4构成。1、手指向一个方向滑动,所有格子会向那个方向运动。2......
  • flutter webview_windows 简单使用
    class_MyHomePageStateextendsState<MyHomePage>{finalWebviewController_webViewController=WebviewController();@overridevoidinitState(){sup......
  • Idea安装并创建Flutter
    开发工具IntelliJIDEA2022.2.4(UltimateEdition)Build#IU-222.4459.24,builtonNovember22,2022 安装插件Flutter、Dart的插件 下载flutter的SDKhttps:......
  • flutter attach failed解决方案
    背景:项目为iOS原生和Flutter混合开发。Flutter之前使用的版本为2.10.2,升级到最新的发现插件获取有问题,后来跟安卓端保持一致将Flutter升级到了3.0.5版本。折腾了一个多星期......
  • 图文并茂记录下重新配置MAC系统Flutter环境
    Flutter是什么Flutter是Google开源的构建用户界面(UI)工具包,帮助开发者通过一套代码库高效构建多平台精美应用,支持移动、Web、桌面和嵌入式平台。Flutter 开源、免费,拥有......
  • flutter系列之:flutter中listview的高级用法
    目录简介ListView的常规用法创建不同类型的items总结简介一般情况下,我们使用Listview的方式是构建要展示的item,然后将这些item传入ListView的构造函数即可,通常情况下这样......
  • Flutter Gestures
    LearntohandleFluttergesturesliketap,press,longpress,drags,etc.Itisveryimportanttoknowtheactionsofuser.Gesturesarephysicalactionandmo......
  • Flutter Widgets
    LearnthebasicconceptofFlutterwidgetsanddifferentwaysofuseittomakeuserinterface.InFlutter,almosteverythingisawidget.Inthistutorial,yo......
  • Flutter 陈航 11-生命周期 WidgetsBindingObserver
    本文地址目录目录目录11|提到生命周期,我们是在说什么?State生命周期生命周期流程图生命周期的三个阶段创建更新销毁注意!!!常见场景的生命周期生命周期方法总结测试代码S......