//! The keyboard input functionality.12// This file contains a substantial portion of the UI Events Specification by the W3C. In3// particular, the variant names within `KeyCode` and their documentation are modified4// versions of contents of the aforementioned specification.5//6// The original documents are:7//8//9// ### For `KeyCode`10// UI Events KeyboardEvent code Values11// https://www.w3.org/TR/2017/CR-uievents-code-20170601/12// Copyright © 2017 W3C® (MIT, ERCIM, Keio, Beihang).13//14// These documents were used under the terms of the following license. This W3C license as well as15// the W3C short notice apply to the `KeyCode` enums and their variants and the16// documentation attached to their variants.1718// --------- BEGINNING OF W3C LICENSE --------------------------------------------------------------19//20// License21//22// By obtaining and/or copying this work, you (the licensee) agree that you have read, understood,23// and will comply with the following terms and conditions.24//25// Permission to copy, modify, and distribute this work, with or without modification, for any26// purpose and without fee or royalty is hereby granted, provided that you include the following on27// ALL copies of the work or portions thereof, including modifications:28//29// - The full text of this NOTICE in a location viewable to users of the redistributed or derivative30// work.31// - Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none32// exist, the W3C Software and Document Short Notice should be included.33// - Notice of any changes or modifications, through a copyright statement on the new code or34// document such as "This software or document includes material copied from or derived from35// [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."36//37// Disclaimers38//39// THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES,40// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR41// ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD42// PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.43//44// COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES45// ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.46//47// The name and trademarks of copyright holders may NOT be used in advertising or publicity48// pertaining to the work without specific, written prior permission. Title to copyright in this49// work will at all times remain with copyright holders.50//51// --------- END OF W3C LICENSE --------------------------------------------------------------------5253// --------- BEGINNING OF W3C SHORT NOTICE ---------------------------------------------------------54//55// winit: https://github.com/rust-windowing/winit56//57// Copyright © 2021 World Wide Web Consortium, (Massachusetts Institute of Technology, European58// Research Consortium for Informatics and Mathematics, Keio University, Beihang). All Rights59// Reserved. This work is distributed under the W3C® Software License [1] in the hope that it will60// be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or61// FITNESS FOR A PARTICULAR PURPOSE.62//63// [1] http://www.w3.org/Consortium/Legal/copyright-software64//65// --------- END OF W3C SHORT NOTICE ---------------------------------------------------------------6667use crate::{ButtonInput, ButtonState};68use bevy_ecs::{69change_detection::DetectChangesMut,70entity::Entity,71event::{BufferedEvent, EventReader},72system::ResMut,73};7475#[cfg(feature = "bevy_reflect")]76use bevy_reflect::Reflect;7778#[cfg(not(feature = "smol_str"))]79use alloc::string::String as SmolStr;8081#[cfg(feature = "smol_str")]82use smol_str::SmolStr;8384#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]85use bevy_reflect::{ReflectDeserialize, ReflectSerialize};8687/// A keyboard input event.88///89/// This event is the translated version of the `WindowEvent::KeyboardInput` from the `winit` crate.90/// It is available to the end user and can be used for game logic.91///92/// ## Usage93///94/// The event is consumed inside of the [`keyboard_input_system`] to update the95/// [`ButtonInput<KeyCode>`](ButtonInput<KeyCode>) and96/// [`ButtonInput<Key>`](ButtonInput<Key>) resources.97#[derive(BufferedEvent, Debug, Clone, PartialEq, Eq, Hash)]98#[cfg_attr(99feature = "bevy_reflect",100derive(Reflect),101reflect(Debug, PartialEq, Hash, Clone)102)]103#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]104#[cfg_attr(105all(feature = "serialize", feature = "bevy_reflect"),106reflect(Serialize, Deserialize)107)]108pub struct KeyboardInput {109/// The physical key code of the key.110///111/// This corresponds to the location of the key independent of the keyboard layout.112pub key_code: KeyCode,113/// The logical key of the input.114///115/// This corresponds to the actual key taking keyboard layout into account.116pub logical_key: Key,117/// The press state of the key.118pub state: ButtonState,119/// Contains the text produced by this keypress.120///121/// In most cases this is identical to the content122/// of the `Character` variant of `logical_key`.123/// However, on Windows when a dead key was pressed earlier124/// but cannot be combined with the character from this125/// keypress, the produced text will consist of two characters:126/// the dead-key-character followed by the character resulting127/// from this keypress.128///129/// This is `None` if the current keypress cannot130/// be interpreted as text.131pub text: Option<SmolStr>,132/// On some systems, holding down a key for some period of time causes that key to be repeated133/// as though it were being pressed and released repeatedly. This field is [`true`] if this134/// event is the result of one of those repeats.135pub repeat: bool,136/// Window that received the input.137pub window: Entity,138}139140/// Gets generated from `bevy_winit::winit_runner`141///142/// Used for clearing all cached states to avoid having 'stuck' key presses143/// when, for example, switching between windows with 'Alt-Tab' or using any other144/// OS specific key combination that leads to Bevy window losing focus and not receiving any145/// input events146#[derive(BufferedEvent, Debug, Clone, PartialEq, Eq)]147#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Clone, PartialEq))]148#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]149#[cfg_attr(150all(feature = "serialize", feature = "bevy_reflect"),151reflect(Serialize, Deserialize)152)]153pub struct KeyboardFocusLost;154155/// Updates the [`ButtonInput<KeyCode>`] and [`ButtonInput<Key>`] resources with the latest [`KeyboardInput`] events.156///157/// ## Differences158///159/// The main difference between the [`KeyboardInput`] event and the [`ButtonInput`] resources are that160/// the latter has convenient functions such as [`ButtonInput::pressed`], [`ButtonInput::just_pressed`] and [`ButtonInput::just_released`] and is window id agnostic.161///162/// There is a [`ButtonInput`] for both [`KeyCode`] and [`Key`] as they are both useful in different situations, see their documentation for the details.163pub fn keyboard_input_system(164mut keycode_input: ResMut<ButtonInput<KeyCode>>,165mut key_input: ResMut<ButtonInput<Key>>,166mut keyboard_input_events: EventReader<KeyboardInput>,167mut focus_events: EventReader<KeyboardFocusLost>,168) {169// Avoid clearing if not empty to ensure change detection is not triggered.170keycode_input.bypass_change_detection().clear();171key_input.bypass_change_detection().clear();172173for event in keyboard_input_events.read() {174let KeyboardInput {175key_code,176logical_key,177state,178..179} = event;180match state {181ButtonState::Pressed => {182keycode_input.press(*key_code);183key_input.press(logical_key.clone());184}185ButtonState::Released => {186keycode_input.release(*key_code);187key_input.release(logical_key.clone());188}189}190}191192// Release all cached input to avoid having stuck input when switching between windows in os193if !focus_events.is_empty() {194keycode_input.release_all();195focus_events.clear();196}197}198199/// Contains the platform-native physical key identifier200///201/// The exact values vary from platform to platform (which is part of why this is a per-platform202/// enum), but the values are primarily tied to the key's physical location on the keyboard.203///204/// This enum is primarily used to store raw keycodes when Winit doesn't map a given native205/// physical key identifier to a meaningful [`KeyCode`] variant. In the presence of identifiers we206/// haven't mapped for you yet, this lets you use [`KeyCode`] to:207///208/// - Correctly match key press and release events.209/// - On non-web platforms, support assigning keybinds to virtually any key through a UI.210#[derive(Debug, Clone, Ord, PartialOrd, Copy, PartialEq, Eq, Hash)]211#[cfg_attr(212feature = "bevy_reflect",213derive(Reflect),214reflect(Clone, PartialEq, Hash)215)]216#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]217#[cfg_attr(218all(feature = "serialize", feature = "bevy_reflect"),219reflect(Serialize, Deserialize)220)]221pub enum NativeKeyCode {222/// Unidentified223Unidentified,224/// An Android "scancode".225Android(u32),226/// A macOS "scancode".227MacOS(u16),228/// A Windows "scancode".229Windows(u16),230/// An XKB "keycode".231Xkb(u32),232}233234/// The key code of a [`KeyboardInput`].235///236/// ## Usage237///238/// It is used as the generic `T` value of an [`ButtonInput`] to create a `Res<ButtonInput<KeyCode>>`.239///240/// Code representing the location of a physical key241/// This mostly conforms to the [`UI Events Specification's KeyboardEvent.code`] with a few242/// exceptions:243/// - The keys that the specification calls `MetaLeft` and `MetaRight` are named `SuperLeft` and244/// `SuperRight` here.245/// - The key that the specification calls "Super" is reported as `Unidentified` here.246///247/// [`UI Events Specification's KeyboardEvent.code`]: https://w3c.github.io/uievents-code/#code-value-tables248///249/// ## Updating250///251/// The resource is updated inside of the [`keyboard_input_system`].252#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]253#[cfg_attr(254feature = "bevy_reflect",255derive(Reflect),256reflect(Debug, Hash, PartialEq, Clone)257)]258#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]259#[cfg_attr(260all(feature = "serialize", feature = "bevy_reflect"),261reflect(Serialize, Deserialize)262)]263#[expect(264clippy::doc_markdown,265reason = "We use camel-case words inside `<kbd>` tags to represent keyboard keys, which are not identifiers that we should be putting inside backticks."266)]267#[repr(u32)]268pub enum KeyCode {269/// This variant is used when the key cannot be translated to any other variant.270///271/// The native keycode is provided (if available) so you're able to more reliably match272/// key-press and key-release events by hashing the [`KeyCode`]. It is also possible to use273/// this for keybinds for non-standard keys, but such keybinds are tied to a given platform.274Unidentified(NativeKeyCode),275/// <kbd>\`</kbd> on a US keyboard. This is also called a backtick or grave.276/// This is the <kbd>半角</kbd>/<kbd>全角</kbd>/<kbd>漢字</kbd>277/// (hankaku/zenkaku/kanji) key on Japanese keyboards278Backquote,279/// Used for both the US <kbd>\\</kbd> (on the 101-key layout) and also for the key280/// located between the <kbd>"</kbd> and <kbd>Enter</kbd> keys on row C of the 102-,281/// 104- and 106-key layouts.282/// Labeled <kbd>#</kbd> on a UK (102) keyboard.283Backslash,284/// <kbd>[</kbd> on a US keyboard.285BracketLeft,286/// <kbd>]</kbd> on a US keyboard.287BracketRight,288/// <kbd>,</kbd> on a US keyboard.289Comma,290/// <kbd>0</kbd> on a US keyboard.291Digit0,292/// <kbd>1</kbd> on a US keyboard.293Digit1,294/// <kbd>2</kbd> on a US keyboard.295Digit2,296/// <kbd>3</kbd> on a US keyboard.297Digit3,298/// <kbd>4</kbd> on a US keyboard.299Digit4,300/// <kbd>5</kbd> on a US keyboard.301Digit5,302/// <kbd>6</kbd> on a US keyboard.303Digit6,304/// <kbd>7</kbd> on a US keyboard.305Digit7,306/// <kbd>8</kbd> on a US keyboard.307Digit8,308/// <kbd>9</kbd> on a US keyboard.309Digit9,310/// <kbd>=</kbd> on a US keyboard.311Equal,312/// Located between the left <kbd>Shift</kbd> and <kbd>Z</kbd> keys.313/// Labeled <kbd>\\</kbd> on a UK keyboard.314IntlBackslash,315/// Located between the <kbd>/</kbd> and right <kbd>Shift</kbd> keys.316/// Labeled <kbd>\\</kbd> (ro) on a Japanese keyboard.317IntlRo,318/// Located between the <kbd>=</kbd> and <kbd>Backspace</kbd> keys.319/// Labeled <kbd>¥</kbd> (yen) on a Japanese keyboard. <kbd>\\</kbd> on a320/// Russian keyboard.321IntlYen,322/// <kbd>a</kbd> on a US keyboard.323/// Labeled <kbd>q</kbd> on an AZERTY (e.g., French) keyboard.324KeyA,325/// <kbd>b</kbd> on a US keyboard.326KeyB,327/// <kbd>c</kbd> on a US keyboard.328KeyC,329/// <kbd>d</kbd> on a US keyboard.330KeyD,331/// <kbd>e</kbd> on a US keyboard.332KeyE,333/// <kbd>f</kbd> on a US keyboard.334KeyF,335/// <kbd>g</kbd> on a US keyboard.336KeyG,337/// <kbd>h</kbd> on a US keyboard.338KeyH,339/// <kbd>i</kbd> on a US keyboard.340KeyI,341/// <kbd>j</kbd> on a US keyboard.342KeyJ,343/// <kbd>k</kbd> on a US keyboard.344KeyK,345/// <kbd>l</kbd> on a US keyboard.346KeyL,347/// <kbd>m</kbd> on a US keyboard.348KeyM,349/// <kbd>n</kbd> on a US keyboard.350KeyN,351/// <kbd>o</kbd> on a US keyboard.352KeyO,353/// <kbd>p</kbd> on a US keyboard.354KeyP,355/// <kbd>q</kbd> on a US keyboard.356/// Labeled <kbd>a</kbd> on an AZERTY (e.g., French) keyboard.357KeyQ,358/// <kbd>r</kbd> on a US keyboard.359KeyR,360/// <kbd>s</kbd> on a US keyboard.361KeyS,362/// <kbd>t</kbd> on a US keyboard.363KeyT,364/// <kbd>u</kbd> on a US keyboard.365KeyU,366/// <kbd>v</kbd> on a US keyboard.367KeyV,368/// <kbd>w</kbd> on a US keyboard.369/// Labeled <kbd>z</kbd> on an AZERTY (e.g., French) keyboard.370KeyW,371/// <kbd>x</kbd> on a US keyboard.372KeyX,373/// <kbd>y</kbd> on a US keyboard.374/// Labeled <kbd>z</kbd> on a QWERTZ (e.g., German) keyboard.375KeyY,376/// <kbd>z</kbd> on a US keyboard.377/// Labeled <kbd>w</kbd> on an AZERTY (e.g., French) keyboard, and <kbd>y</kbd> on a378/// QWERTZ (e.g., German) keyboard.379KeyZ,380/// <kbd>-</kbd> on a US keyboard.381Minus,382/// <kbd>.</kbd> on a US keyboard.383Period,384/// <kbd>'</kbd> on a US keyboard.385Quote,386/// <kbd>;</kbd> on a US keyboard.387Semicolon,388/// <kbd>/</kbd> on a US keyboard.389Slash,390/// <kbd>Alt</kbd>, <kbd>Option</kbd>, or <kbd>⌥</kbd>.391AltLeft,392/// <kbd>Alt</kbd>, <kbd>Option</kbd>, or <kbd>⌥</kbd>.393/// This is labeled <kbd>AltGr</kbd> on many keyboard layouts.394AltRight,395/// <kbd>Backspace</kbd> or <kbd>⌫</kbd>.396/// Labeled <kbd>Delete</kbd> on Apple keyboards.397Backspace,398/// <kbd>CapsLock</kbd> or <kbd>⇪</kbd>399CapsLock,400/// The application context menu key, which is typically found between the right401/// <kbd>Super</kbd> key and the right <kbd>Control</kbd> key.402ContextMenu,403/// <kbd>Control</kbd> or <kbd>⌃</kbd>404ControlLeft,405/// <kbd>Control</kbd> or <kbd>⌃</kbd>406ControlRight,407/// <kbd>Enter</kbd> or <kbd>↵</kbd>. Labeled <kbd>Return</kbd> on Apple keyboards.408Enter,409/// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.410SuperLeft,411/// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.412SuperRight,413/// <kbd>Shift</kbd> or <kbd>⇧</kbd>414ShiftLeft,415/// <kbd>Shift</kbd> or <kbd>⇧</kbd>416ShiftRight,417/// <kbd> </kbd> (space)418Space,419/// <kbd>Tab</kbd> or <kbd>⇥</kbd>420Tab,421/// Japanese: <kbd>変</kbd> (henkan)422Convert,423/// Japanese: <kbd>カタカナ</kbd>/<kbd>ひらがな</kbd>/<kbd>ローマ字</kbd> (katakana/hiragana/romaji)424KanaMode,425/// Korean: HangulMode <kbd>한/영</kbd> (han/yeong)426///427/// Japanese (Mac keyboard): <kbd>か</kbd> (kana)428Lang1,429/// Korean: Hanja <kbd>한</kbd> (hanja)430///431/// Japanese (Mac keyboard): <kbd>英</kbd> (eisu)432Lang2,433/// Japanese (word-processing keyboard): Katakana434Lang3,435/// Japanese (word-processing keyboard): Hiragana436Lang4,437/// Japanese (word-processing keyboard): Zenkaku/Hankaku438Lang5,439/// Japanese: <kbd>無変換</kbd> (muhenkan)440NonConvert,441/// <kbd>⌦</kbd>. The forward delete key.442/// Note that on Apple keyboards, the key labeled <kbd>Delete</kbd> on the main part of443/// the keyboard is encoded as [`Backspace`].444///445/// [`Backspace`]: Self::Backspace446Delete,447/// <kbd>Page Down</kbd>, <kbd>End</kbd>, or <kbd>↘</kbd>448End,449/// <kbd>Help</kbd>. Not present on standard PC keyboards.450Help,451/// <kbd>Home</kbd> or <kbd>↖</kbd>452Home,453/// <kbd>Insert</kbd> or <kbd>Ins</kbd>. Not present on Apple keyboards.454Insert,455/// <kbd>Page Down</kbd>, <kbd>PgDn</kbd>, or <kbd>⇟</kbd>456PageDown,457/// <kbd>Page Up</kbd>, <kbd>PgUp</kbd>, or <kbd>⇞</kbd>458PageUp,459/// <kbd>↓</kbd>460ArrowDown,461/// <kbd>←</kbd>462ArrowLeft,463/// <kbd>→</kbd>464ArrowRight,465/// <kbd>↑</kbd>466ArrowUp,467/// On the Mac, this is used for the numpad <kbd>Clear</kbd> key.468NumLock,469/// <kbd>0 Ins</kbd> on a keyboard. <kbd>0</kbd> on a phone or remote control470Numpad0,471/// <kbd>1 End</kbd> on a keyboard. <kbd>1</kbd> or <kbd>1 QZ</kbd> on a phone or remote control472Numpad1,473/// <kbd>2 ↓</kbd> on a keyboard. <kbd>2 ABC</kbd> on a phone or remote control474Numpad2,475/// <kbd>3 PgDn</kbd> on a keyboard. <kbd>3 DEF</kbd> on a phone or remote control476Numpad3,477/// <kbd>4 ←</kbd> on a keyboard. <kbd>4 GHI</kbd> on a phone or remote control478Numpad4,479/// <kbd>5</kbd> on a keyboard. <kbd>5 JKL</kbd> on a phone or remote control480Numpad5,481/// <kbd>6 →</kbd> on a keyboard. <kbd>6 MNO</kbd> on a phone or remote control482Numpad6,483/// <kbd>7 Home</kbd> on a keyboard. <kbd>7 PQRS</kbd> or <kbd>7 PRS</kbd> on a phone484/// or remote control485Numpad7,486/// <kbd>8 ↑</kbd> on a keyboard. <kbd>8 TUV</kbd> on a phone or remote control487Numpad8,488/// <kbd>9 PgUp</kbd> on a keyboard. <kbd>9 WXYZ</kbd> or <kbd>9 WXY</kbd> on a phone489/// or remote control490Numpad9,491/// <kbd>+</kbd>492NumpadAdd,493/// Found on the Microsoft Natural Keyboard.494NumpadBackspace,495/// <kbd>C</kbd> or <kbd>A</kbd> (All Clear). Also for use with numpads that have a496/// <kbd>Clear</kbd> key that is separate from the <kbd>NumLock</kbd> key. On the Mac, the497/// numpad <kbd>Clear</kbd> key is encoded as [`NumLock`].498///499/// [`NumLock`]: Self::NumLock500NumpadClear,501/// <kbd>C</kbd> (Clear Entry)502NumpadClearEntry,503/// <kbd>,</kbd> (thousands separator). For locales where the thousands separator504/// is a "." (e.g., Brazil), this key may generate a <kbd>.</kbd>.505NumpadComma,506/// <kbd>. Del</kbd>. For locales where the decimal separator is "," (e.g.,507/// Brazil), this key may generate a <kbd>,</kbd>.508NumpadDecimal,509/// <kbd>/</kbd>510NumpadDivide,511/// The Enter key on the numpad.512NumpadEnter,513/// <kbd>=</kbd>514NumpadEqual,515/// <kbd>#</kbd> on a phone or remote control device. This key is typically found516/// below the <kbd>9</kbd> key and to the right of the <kbd>0</kbd> key.517NumpadHash,518/// <kbd>M</kbd> Add current entry to the value stored in memory.519NumpadMemoryAdd,520/// <kbd>M</kbd> Clear the value stored in memory.521NumpadMemoryClear,522/// <kbd>M</kbd> Replace the current entry with the value stored in memory.523NumpadMemoryRecall,524/// <kbd>M</kbd> Replace the value stored in memory with the current entry.525NumpadMemoryStore,526/// <kbd>M</kbd> Subtract current entry from the value stored in memory.527NumpadMemorySubtract,528/// <kbd>*</kbd> on a keyboard. For use with numpads that provide mathematical529/// operations (<kbd>+</kbd>, <kbd>-</kbd> <kbd>*</kbd> and <kbd>/</kbd>).530///531/// Use `NumpadStar` for the <kbd>*</kbd> key on phones and remote controls.532NumpadMultiply,533/// <kbd>(</kbd> Found on the Microsoft Natural Keyboard.534NumpadParenLeft,535/// <kbd>)</kbd> Found on the Microsoft Natural Keyboard.536NumpadParenRight,537/// <kbd>*</kbd> on a phone or remote control device.538///539/// This key is typically found below the <kbd>7</kbd> key and to the left of540/// the <kbd>0</kbd> key.541///542/// Use <kbd>"NumpadMultiply"</kbd> for the <kbd>*</kbd> key on543/// numeric keypads.544NumpadStar,545/// <kbd>-</kbd>546NumpadSubtract,547/// <kbd>Esc</kbd> or <kbd>⎋</kbd>548Escape,549/// <kbd>Fn</kbd> This is typically a hardware key that does not generate a separate code.550Fn,551/// <kbd>FLock</kbd> or <kbd>FnLock</kbd>. Function Lock key. Found on the Microsoft552/// Natural Keyboard.553FnLock,554/// <kbd>PrtScr SysRq</kbd> or <kbd>Print Screen</kbd>555PrintScreen,556/// <kbd>Scroll Lock</kbd>557ScrollLock,558/// <kbd>Pause Break</kbd>559Pause,560/// Some laptops place this key to the left of the <kbd>↑</kbd> key.561///562/// This also the "back" button (triangle) on Android.563BrowserBack,564/// BrowserFavorites565BrowserFavorites,566/// Some laptops place this key to the right of the <kbd>↑</kbd> key.567BrowserForward,568/// The "home" button on Android.569BrowserHome,570/// BrowserRefresh571BrowserRefresh,572/// BrowserSearch573BrowserSearch,574/// BrowserStop575BrowserStop,576/// <kbd>Eject</kbd> or <kbd>⏏</kbd>. This key is placed in the function section on some Apple577/// keyboards.578Eject,579/// Sometimes labeled <kbd>My Computer</kbd> on the keyboard580LaunchApp1,581/// Sometimes labeled <kbd>Calculator</kbd> on the keyboard582LaunchApp2,583/// LaunchMail584LaunchMail,585/// MediaPlayPause586MediaPlayPause,587/// MediaSelect588MediaSelect,589/// MediaStop590MediaStop,591/// MediaTrackNext592MediaTrackNext,593/// MediaTrackPrevious594MediaTrackPrevious,595/// This key is placed in the function section on some Apple keyboards, replacing the596/// <kbd>Eject</kbd> key.597Power,598/// Sleep599Sleep,600/// AudioVolumeDown601AudioVolumeDown,602/// AudioVolumeMute603AudioVolumeMute,604/// AudioVolumeUp605AudioVolumeUp,606/// WakeUp607WakeUp,608/// Legacy modifier key. Also called "Super" in certain places.609Meta,610/// Legacy modifier key.611Hyper,612/// Turbo613Turbo,614/// Abort615Abort,616/// Resume617Resume,618/// Suspend619Suspend,620/// Found on Sun’s USB keyboard.621Again,622/// Found on Sun’s USB keyboard.623Copy,624/// Found on Sun’s USB keyboard.625Cut,626/// Found on Sun’s USB keyboard.627Find,628/// Found on Sun’s USB keyboard.629Open,630/// Found on Sun’s USB keyboard.631Paste,632/// Found on Sun’s USB keyboard.633Props,634/// Found on Sun’s USB keyboard.635Select,636/// Found on Sun’s USB keyboard.637Undo,638/// Use for dedicated <kbd>ひらがな</kbd> key found on some Japanese word processing keyboards.639Hiragana,640/// Use for dedicated <kbd>カタカナ</kbd> key found on some Japanese word processing keyboards.641Katakana,642/// General-purpose function key.643/// Usually found at the top of the keyboard.644F1,645/// General-purpose function key.646/// Usually found at the top of the keyboard.647F2,648/// General-purpose function key.649/// Usually found at the top of the keyboard.650F3,651/// General-purpose function key.652/// Usually found at the top of the keyboard.653F4,654/// General-purpose function key.655/// Usually found at the top of the keyboard.656F5,657/// General-purpose function key.658/// Usually found at the top of the keyboard.659F6,660/// General-purpose function key.661/// Usually found at the top of the keyboard.662F7,663/// General-purpose function key.664/// Usually found at the top of the keyboard.665F8,666/// General-purpose function key.667/// Usually found at the top of the keyboard.668F9,669/// General-purpose function key.670/// Usually found at the top of the keyboard.671F10,672/// General-purpose function key.673/// Usually found at the top of the keyboard.674F11,675/// General-purpose function key.676/// Usually found at the top of the keyboard.677F12,678/// General-purpose function key.679/// Usually found at the top of the keyboard.680F13,681/// General-purpose function key.682/// Usually found at the top of the keyboard.683F14,684/// General-purpose function key.685/// Usually found at the top of the keyboard.686F15,687/// General-purpose function key.688/// Usually found at the top of the keyboard.689F16,690/// General-purpose function key.691/// Usually found at the top of the keyboard.692F17,693/// General-purpose function key.694/// Usually found at the top of the keyboard.695F18,696/// General-purpose function key.697/// Usually found at the top of the keyboard.698F19,699/// General-purpose function key.700/// Usually found at the top of the keyboard.701F20,702/// General-purpose function key.703/// Usually found at the top of the keyboard.704F21,705/// General-purpose function key.706/// Usually found at the top of the keyboard.707F22,708/// General-purpose function key.709/// Usually found at the top of the keyboard.710F23,711/// General-purpose function key.712/// Usually found at the top of the keyboard.713F24,714/// General-purpose function key.715F25,716/// General-purpose function key.717F26,718/// General-purpose function key.719F27,720/// General-purpose function key.721F28,722/// General-purpose function key.723F29,724/// General-purpose function key.725F30,726/// General-purpose function key.727F31,728/// General-purpose function key.729F32,730/// General-purpose function key.731F33,732/// General-purpose function key.733F34,734/// General-purpose function key.735F35,736}737738/// Contains the platform-native logical key identifier, known as keysym.739///740/// Exactly what that means differs from platform to platform, but the values are to some degree741/// tied to the currently active keyboard layout. The same key on the same keyboard may also report742/// different values on different platforms, which is one of the reasons this is a per-platform743/// enum.744///745/// This enum is primarily used to store raw keysym when Winit doesn't map a given native logical746/// key identifier to a meaningful [`Key`] variant. This lets you use [`Key`], and let the user747/// define keybinds which work in the presence of identifiers we haven't mapped for you yet.748#[derive(Debug, Clone, Ord, PartialOrd, PartialEq, Eq, Hash)]749#[cfg_attr(750feature = "bevy_reflect",751derive(Reflect),752reflect(Debug, Hash, PartialEq, Clone)753)]754#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]755#[cfg_attr(756all(feature = "serialize", feature = "bevy_reflect"),757reflect(Serialize, Deserialize)758)]759pub enum NativeKey {760/// Unidentified761Unidentified,762/// An Android "keycode", which is similar to a "virtual-key code" on Windows.763Android(u32),764/// A macOS "scancode". There does not appear to be any direct analogue to either keysyms or765/// "virtual-key" codes in macOS, so we report the scancode instead.766MacOS(u16),767/// A Windows "virtual-key code".768Windows(u16),769/// An XKB "keysym".770Xkb(u32),771/// A "key value string".772Web(SmolStr),773}774775/// The logical key code of a [`KeyboardInput`].776///777/// This contains the actual value that is produced by pressing the key. This is778/// useful when you need the actual letters, and for symbols like `+` and `-`779/// when implementing zoom, as they can be in different locations depending on780/// the keyboard layout.781///782/// In many cases you want the key location instead, for example when783/// implementing WASD controls so the keys are located the same place on QWERTY784/// and other layouts. In that case use [`KeyCode`] instead.785///786/// ## Usage787///788/// It is used as the generic `T` value of an [`ButtonInput`] to create a `Res<ButtonInput<Key>>`.789///790/// ## Technical791///792/// Its values map 1 to 1 to winit's Key.793#[non_exhaustive]794#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone)]795#[cfg_attr(796feature = "bevy_reflect",797derive(Reflect),798reflect(Debug, Hash, PartialEq, Clone)799)]800#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]801#[cfg_attr(802all(feature = "serialize", feature = "bevy_reflect"),803reflect(Serialize, Deserialize)804)]805#[expect(806clippy::doc_markdown,807reason = "We use camel-case words inside `<kbd>` tags to represent keyboard keys, which are not identifiers that we should be putting inside backticks."808)]809pub enum Key {810/// A key string that corresponds to the character typed by the user, taking into account the811/// user’s current locale setting, and any system-level keyboard mapping overrides that are in812/// effect.813///814/// Note that behavior may vary across platforms and keyboard layouts.815/// See the `text` field of [`KeyboardInput`] for more information.816Character(SmolStr),817818/// This variant is used when the key cannot be translated to any other variant.819///820/// The native key is provided (if available) in order to allow the user to specify keybindings821/// for keys which are not defined by this API, mainly through some sort of UI.822Unidentified(NativeKey),823824/// Contains the text representation of the dead-key when available.825///826/// ## Platform-specific827/// - **Web:** Always contains `None`828Dead(Option<char>),829830/// The `Alt` (Alternative) key.831///832/// This key enables the alternate modifier function for interpreting concurrent or subsequent833/// keyboard input. This key value is also used for the Apple <kbd>Option</kbd> key.834Alt,835/// The Alternate Graphics (<kbd>AltGr</kbd> or <kbd>AltGraph</kbd>) key.836///837/// This key is used enable the ISO Level 3 shift modifier (the standard `Shift` key is the838/// level 2 modifier).839AltGraph,840/// The `Caps Lock` (Capital) key.841///842/// Toggle capital character lock function for interpreting subsequent keyboard input event.843CapsLock,844/// The `Control` or `Ctrl` key.845///846/// Used to enable control modifier function for interpreting concurrent or subsequent keyboard847/// input.848Control,849/// The Function switch `Fn` key. Activating this key simultaneously with another key changes850/// that key’s value to an alternate character or function. This key is often handled directly851/// in the keyboard hardware and does not usually generate key events.852Fn,853/// The Function-Lock (`FnLock` or `F-Lock`) key. Activating this key switches the mode of the854/// keyboard to changes some keys' values to an alternate character or function. This key is855/// often handled directly in the keyboard hardware and does not usually generate key events.856FnLock,857/// The `NumLock` or Number Lock key. Used to toggle numpad mode function for interpreting858/// subsequent keyboard input.859NumLock,860/// Toggle between scrolling and cursor movement modes.861ScrollLock,862/// Used to enable shift modifier function for interpreting concurrent or subsequent keyboard863/// input.864Shift,865/// The Symbol modifier key (used on some virtual keyboards).866Symbol,867/// The SymbolLock key, only on web.868SymbolLock,869/// Legacy modifier key. Also called "Super" in certain places.870Meta,871/// Legacy modifier key.872Hyper,873/// Used to enable "super" modifier function for interpreting concurrent or subsequent keyboard874/// input. This key value is used for the "Windows Logo" key and the Apple `Command` or `⌘` key.875///876/// Note: In some contexts (e.g. the Web) this is referred to as the "Meta" key.877Super,878/// The `Enter` or `↵` key. Used to activate current selection or accept current input. This key879/// value is also used for the `Return` (Macintosh numpad) key. This key value is also used for880/// the Android `KEYCODE_DPAD_CENTER`.881Enter,882/// The Horizontal Tabulation `Tab` key.883Tab,884/// Used in text to insert a space between words. Usually located below the character keys.885Space,886/// Navigate or traverse downward. (`KEYCODE_DPAD_DOWN`)887ArrowDown,888/// Navigate or traverse leftward. (`KEYCODE_DPAD_LEFT`)889ArrowLeft,890/// Navigate or traverse rightward. (`KEYCODE_DPAD_RIGHT`)891ArrowRight,892/// Navigate or traverse upward. (`KEYCODE_DPAD_UP`)893ArrowUp,894/// The End key, used with keyboard entry to go to the end of content (`KEYCODE_MOVE_END`).895End,896/// The Home key, used with keyboard entry, to go to start of content (`KEYCODE_MOVE_HOME`).897/// For the mobile phone `Home` key (which goes to the phone’s main screen), use [`GoHome`].898///899/// [`GoHome`]: Self::GoHome900Home,901/// Scroll down or display next page of content.902PageDown,903/// Scroll up or display previous page of content.904PageUp,905/// Used to remove the character to the left of the cursor. This key value is also used for906/// the key labeled `Delete` on macOS keyboards.907Backspace,908/// Remove the currently selected input.909Clear,910/// Copy the current selection. (`APPCOMMAND_COPY`)911Copy,912/// The Cursor Select key.913CrSel,914/// Cut the current selection. (`APPCOMMAND_CUT`)915Cut,916/// Used to delete the character to the right of the cursor. This key value is also used for the917/// key labeled `Delete` on macOS keyboards when `Fn` is active.918Delete,919/// The Erase to End of Field key. This key deletes all characters from the current cursor920/// position to the end of the current field.921EraseEof,922/// The Extend Selection (Exsel) key.923ExSel,924/// Toggle between text modes for insertion or overtyping.925/// (`KEYCODE_INSERT`)926Insert,927/// The Paste key. (`APPCOMMAND_PASTE`)928Paste,929/// Redo the last action. (`APPCOMMAND_REDO`)930Redo,931/// Undo the last action. (`APPCOMMAND_UNDO`)932Undo,933/// The Accept (Commit, OK) key. Accept current option or input method sequence conversion.934Accept,935/// Redo or repeat an action.936Again,937/// The Attention (Attn) key.938Attn,939/// The Cancel key. (on linux and web)940Cancel,941/// Show the application’s context menu.942/// This key is commonly found between the right `Super` key and the right `Control` key.943ContextMenu,944/// The `Esc` key. This key was originally used to initiate an escape sequence, but is945/// now more generally used to exit or "escape" the current context, such as closing a dialog946/// or exiting full screen mode.947Escape,948/// The Execute key.949Execute,950/// Open the Find dialog. (`APPCOMMAND_FIND`)951Find,952/// Open a help dialog or toggle display of help information. (`APPCOMMAND_HELP`,953/// `KEYCODE_HELP`)954Help,955/// Pause the current state or application (as appropriate).956///957/// Note: Do not use this value for the `Pause` button on media controllers. Use `"MediaPause"`958/// instead.959Pause,960/// Play or resume the current state or application (as appropriate).961///962/// Note: Do not use this value for the `Play` button on media controllers. Use `"MediaPlay"`963/// instead.964Play,965/// The properties (Props) key.966Props,967/// The Select key.968Select,969/// The ZoomIn key. (`KEYCODE_ZOOM_IN`)970ZoomIn,971/// The ZoomOut key. (`KEYCODE_ZOOM_OUT`)972ZoomOut,973/// The Brightness Down key. Typically controls the display brightness.974/// (`KEYCODE_BRIGHTNESS_DOWN`)975BrightnessDown,976/// The Brightness Up key. Typically controls the display brightness. (`KEYCODE_BRIGHTNESS_UP`)977BrightnessUp,978/// Toggle removable media to eject (open) and insert (close) state. (`KEYCODE_MEDIA_EJECT`)979Eject,980/// LogOff981LogOff,982/// Toggle power state. (`KEYCODE_POWER`)983/// Note: Some devices might not expose this key to the operating environment.984Power,985/// The `PowerOff` key. Sometime called `PowerDown`.986PowerOff,987/// Initiate print-screen function.988PrintScreen,989/// The Hibernate key. This key saves the current state of the computer to disk so that it can990/// be restored. The computer will then shutdown.991Hibernate,992/// The Standby key. This key turns off the display and places the computer into a low-power993/// mode without completely shutting down. It is sometimes labeled `Suspend` or `Sleep` key.994/// (`KEYCODE_SLEEP`)995Standby,996/// The WakeUp key. (`KEYCODE_WAKEUP`)997WakeUp,998/// Initiate the multi-candidate mode.999AllCandidates,1000/// The Alphanumeric key (on linux/web)1001Alphanumeric,1002/// Initiate the Code Input mode to allow characters to be entered by1003/// their code points.1004CodeInput,1005/// The Compose key, also known as "Multi_key" on the X Window System. This key acts in a1006/// manner similar to a dead key, triggering a mode where subsequent key presses are combined to1007/// produce a different character.1008Compose,1009/// Convert the current input method sequence.1010Convert,1011/// The Final Mode `Final` key used on some Asian keyboards, to enable the final mode for IMEs.1012FinalMode,1013/// Switch to the first character group. (ISO/IEC 9995)1014GroupFirst,1015/// Switch to the last character group. (ISO/IEC 9995)1016GroupLast,1017/// Switch to the next character group. (ISO/IEC 9995)1018GroupNext,1019/// Switch to the previous character group. (ISO/IEC 9995)1020GroupPrevious,1021/// Toggle between or cycle through input modes of IMEs.1022ModeChange,1023/// NextCandidate, web only.1024NextCandidate,1025/// Accept current input method sequence without1026/// conversion in IMEs.1027NonConvert,1028/// PreviousCandidate, web only.1029PreviousCandidate,1030/// IME PROCESS key1031Process,1032/// SingleCandidate1033SingleCandidate,1034/// Toggle between Hangul and English modes.1035HangulMode,1036/// HanjaMode1037HanjaMode,1038/// JunjaMode1039JunjaMode,1040/// The Eisu key. This key may close the IME, but its purpose is defined by the current IME.1041/// (`KEYCODE_EISU`)1042Eisu,1043/// The (Half-Width) Characters key.1044Hankaku,1045/// The Hiragana (Japanese Kana characters) key.1046Hiragana,1047/// The Hiragana/Katakana toggle key. (`KEYCODE_KATAKANA_HIRAGANA`)1048HiraganaKatakana,1049/// The Kana Mode (Kana Lock) key. This key is used to enter hiragana mode (typically from1050/// romaji mode).1051KanaMode,1052/// The Kanji (Japanese name for ideographic characters of Chinese origin) Mode key. This key is1053/// typically used to switch to a hiragana keyboard for the purpose of converting input into1054/// kanji. (`KEYCODE_KANA`)1055KanjiMode,1056/// The Katakana (Japanese Kana characters) key.1057Katakana,1058/// The Roman characters function key.1059Romaji,1060/// The Zenkaku (Full-Width) Characters key.1061Zenkaku,1062/// The Zenkaku/Hankaku (full-width/half-width) toggle key. (`KEYCODE_ZENKAKU_HANKAKU`)1063ZenkakuHankaku,1064/// General purpose virtual function key, as index 1.1065Soft1,1066/// General purpose virtual function key, as index 2.1067Soft2,1068/// General purpose virtual function key, as index 3.1069Soft3,1070/// General purpose virtual function key, as index 4.1071Soft4,1072/// Select next (numerically or logically) lower channel. (`APPCOMMAND_MEDIA_CHANNEL_DOWN`,1073/// `KEYCODE_CHANNEL_DOWN`)1074ChannelDown,1075/// Select next (numerically or logically) higher channel. (`APPCOMMAND_MEDIA_CHANNEL_UP`,1076/// `KEYCODE_CHANNEL_UP`)1077ChannelUp,1078/// Close the current document or message (Note: This doesn’t close the application).1079/// (`APPCOMMAND_CLOSE`)1080Close,1081/// Open an editor to forward the current message. (`APPCOMMAND_FORWARD_MAIL`)1082MailForward,1083/// Open an editor to reply to the current message. (`APPCOMMAND_REPLY_TO_MAIL`)1084MailReply,1085/// Send the current message. (`APPCOMMAND_SEND_MAIL`)1086MailSend,1087/// Close the current media, for example to close a CD or DVD tray. (`KEYCODE_MEDIA_CLOSE`)1088MediaClose,1089/// Initiate or continue forward playback at faster than normal speed, or increase speed if1090/// already fast forwarding. (`APPCOMMAND_MEDIA_FAST_FORWARD`, `KEYCODE_MEDIA_FAST_FORWARD`)1091MediaFastForward,1092/// Pause the currently playing media. (`APPCOMMAND_MEDIA_PAUSE`, `KEYCODE_MEDIA_PAUSE`)1093///1094/// Note: Media controller devices should use this value rather than `"Pause"` for their pause1095/// keys.1096MediaPause,1097/// Initiate or continue media playback at normal speed, if not currently playing at normal1098/// speed. (`APPCOMMAND_MEDIA_PLAY`, `KEYCODE_MEDIA_PLAY`)1099MediaPlay,1100/// Toggle media between play and pause states. (`APPCOMMAND_MEDIA_PLAY_PAUSE`,1101/// `KEYCODE_MEDIA_PLAY_PAUSE`)1102MediaPlayPause,1103/// Initiate or resume recording of currently selected media. (`APPCOMMAND_MEDIA_RECORD`,1104/// `KEYCODE_MEDIA_RECORD`)1105MediaRecord,1106/// Initiate or continue reverse playback at faster than normal speed, or increase speed if1107/// already rewinding. (`APPCOMMAND_MEDIA_REWIND`, `KEYCODE_MEDIA_REWIND`)1108MediaRewind,1109/// Stop media playing, pausing, forwarding, rewinding, or recording, if not already stopped.1110/// (`APPCOMMAND_MEDIA_STOP`, `KEYCODE_MEDIA_STOP`)1111MediaStop,1112/// Seek to next media or program track. (`APPCOMMAND_MEDIA_NEXTTRACK`, `KEYCODE_MEDIA_NEXT`)1113MediaTrackNext,1114/// Seek to previous media or program track. (`APPCOMMAND_MEDIA_PREVIOUSTRACK`,1115/// `KEYCODE_MEDIA_PREVIOUS`)1116MediaTrackPrevious,1117/// Open a new document or message. (`APPCOMMAND_NEW`)1118New,1119/// Open an existing document or message. (`APPCOMMAND_OPEN`)1120Open,1121/// Print the current document or message. (`APPCOMMAND_PRINT`)1122Print,1123/// Save the current document or message. (`APPCOMMAND_SAVE`)1124Save,1125/// Spellcheck the current document or selection. (`APPCOMMAND_SPELL_CHECK`)1126SpellCheck,1127/// The `11` key found on media numpads that1128/// have buttons from `1` ... `12`.1129Key11,1130/// The `12` key found on media numpads that1131/// have buttons from `1` ... `12`.1132Key12,1133/// Adjust audio balance leftward. (`VK_AUDIO_BALANCE_LEFT`)1134AudioBalanceLeft,1135/// Adjust audio balance rightward. (`VK_AUDIO_BALANCE_RIGHT`)1136AudioBalanceRight,1137/// Decrease audio bass boost or cycle down through bass boost states. (`APPCOMMAND_BASS_DOWN`,1138/// `VK_BASS_BOOST_DOWN`)1139AudioBassBoostDown,1140/// Toggle bass boost on/off. (`APPCOMMAND_BASS_BOOST`)1141AudioBassBoostToggle,1142/// Increase audio bass boost or cycle up through bass boost states. (`APPCOMMAND_BASS_UP`,1143/// `VK_BASS_BOOST_UP`)1144AudioBassBoostUp,1145/// Adjust audio fader towards front. (`VK_FADER_FRONT`)1146AudioFaderFront,1147/// Adjust audio fader towards rear. (`VK_FADER_REAR`)1148AudioFaderRear,1149/// Advance surround audio mode to next available mode. (`VK_SURROUND_MODE_NEXT`)1150AudioSurroundModeNext,1151/// Decrease treble. (`APPCOMMAND_TREBLE_DOWN`)1152AudioTrebleDown,1153/// Increase treble. (`APPCOMMAND_TREBLE_UP`)1154AudioTrebleUp,1155/// Decrease audio volume. (`APPCOMMAND_VOLUME_DOWN`, `KEYCODE_VOLUME_DOWN`)1156AudioVolumeDown,1157/// Increase audio volume. (`APPCOMMAND_VOLUME_UP`, `KEYCODE_VOLUME_UP`)1158AudioVolumeUp,1159/// Toggle between muted state and prior volume level. (`APPCOMMAND_VOLUME_MUTE`,1160/// `KEYCODE_VOLUME_MUTE`)1161AudioVolumeMute,1162/// Toggle the microphone on/off. (`APPCOMMAND_MIC_ON_OFF_TOGGLE`)1163MicrophoneToggle,1164/// Decrease microphone volume. (`APPCOMMAND_MICROPHONE_VOLUME_DOWN`)1165MicrophoneVolumeDown,1166/// Increase microphone volume. (`APPCOMMAND_MICROPHONE_VOLUME_UP`)1167MicrophoneVolumeUp,1168/// Mute the microphone. (`APPCOMMAND_MICROPHONE_VOLUME_MUTE`, `KEYCODE_MUTE`)1169MicrophoneVolumeMute,1170/// Show correction list when a word is incorrectly identified. (`APPCOMMAND_CORRECTION_LIST`)1171SpeechCorrectionList,1172/// Toggle between dictation mode and command/control mode.1173/// (`APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE`)1174SpeechInputToggle,1175/// The first generic "LaunchApplication" key. This is commonly associated with launching "My1176/// Computer", and may have a computer symbol on the key. (`APPCOMMAND_LAUNCH_APP1`)1177LaunchApplication1,1178/// The second generic "LaunchApplication" key. This is commonly associated with launching1179/// "Calculator", and may have a calculator symbol on the key. (`APPCOMMAND_LAUNCH_APP2`,1180/// `KEYCODE_CALCULATOR`)1181LaunchApplication2,1182/// The "Calendar" key. (`KEYCODE_CALENDAR`)1183LaunchCalendar,1184/// The "Contacts" key. (`KEYCODE_CONTACTS`)1185LaunchContacts,1186/// The "Mail" key. (`APPCOMMAND_LAUNCH_MAIL`)1187LaunchMail,1188/// The "Media Player" key. (`APPCOMMAND_LAUNCH_MEDIA_SELECT`)1189LaunchMediaPlayer,1190/// LaunchMusicPlayer1191LaunchMusicPlayer,1192/// LaunchPhone1193LaunchPhone,1194/// LaunchScreenSaver1195LaunchScreenSaver,1196/// LaunchSpreadsheet1197LaunchSpreadsheet,1198/// LaunchWebBrowser1199LaunchWebBrowser,1200/// LaunchWebCam1201LaunchWebCam,1202/// LaunchWordProcessor1203LaunchWordProcessor,1204/// Navigate to previous content or page in current history. (`APPCOMMAND_BROWSER_BACKWARD`)1205BrowserBack,1206/// Open the list of browser favorites. (`APPCOMMAND_BROWSER_FAVORITES`)1207BrowserFavorites,1208/// Navigate to next content or page in current history. (`APPCOMMAND_BROWSER_FORWARD`)1209BrowserForward,1210/// Go to the user’s preferred home page. (`APPCOMMAND_BROWSER_HOME`)1211BrowserHome,1212/// Refresh the current page or content. (`APPCOMMAND_BROWSER_REFRESH`)1213BrowserRefresh,1214/// Call up the user’s preferred search page. (`APPCOMMAND_BROWSER_SEARCH`)1215BrowserSearch,1216/// Stop loading the current page or content. (`APPCOMMAND_BROWSER_STOP`)1217BrowserStop,1218/// The Application switch key, which provides a list of recent apps to switch between.1219/// (`KEYCODE_APP_SWITCH`)1220AppSwitch,1221/// The Call key. (`KEYCODE_CALL`)1222Call,1223/// The Camera key. (`KEYCODE_CAMERA`)1224Camera,1225/// The Camera focus key. (`KEYCODE_FOCUS`)1226CameraFocus,1227/// The End Call key. (`KEYCODE_ENDCALL`)1228EndCall,1229/// The Back key. (`KEYCODE_BACK`)1230GoBack,1231/// The Home key, which goes to the phone’s main screen. (`KEYCODE_HOME`)1232GoHome,1233/// The Headset Hook key. (`KEYCODE_HEADSETHOOK`)1234HeadsetHook,1235/// LastNumberRedial1236LastNumberRedial,1237/// The Notification key. (`KEYCODE_NOTIFICATION`)1238Notification,1239/// Toggle between manner mode state: silent, vibrate, ring, ... (`KEYCODE_MANNER_MODE`)1240MannerMode,1241/// VoiceDial1242VoiceDial,1243/// Switch to viewing TV. (`KEYCODE_TV`)1244TV,1245/// TV 3D Mode. (`KEYCODE_3D_MODE`)1246TV3DMode,1247/// Toggle between antenna and cable input. (`KEYCODE_TV_ANTENNA_CABLE`)1248TVAntennaCable,1249/// Audio description. (`KEYCODE_TV_AUDIO_DESCRIPTION`)1250TVAudioDescription,1251/// Audio description mixing volume down. (`KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN`)1252TVAudioDescriptionMixDown,1253/// Audio description mixing volume up. (`KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP`)1254TVAudioDescriptionMixUp,1255/// Contents menu. (`KEYCODE_TV_CONTENTS_MENU`)1256TVContentsMenu,1257/// Contents menu. (`KEYCODE_TV_DATA_SERVICE`)1258TVDataService,1259/// Switch the input mode on an external TV. (`KEYCODE_TV_INPUT`)1260TVInput,1261/// Switch to component input #1. (`KEYCODE_TV_INPUT_COMPONENT_1`)1262TVInputComponent1,1263/// Switch to component input #2. (`KEYCODE_TV_INPUT_COMPONENT_2`)1264TVInputComponent2,1265/// Switch to composite input #1. (`KEYCODE_TV_INPUT_COMPOSITE_1`)1266TVInputComposite1,1267/// Switch to composite input #2. (`KEYCODE_TV_INPUT_COMPOSITE_2`)1268TVInputComposite2,1269/// Switch to HDMI input #1. (`KEYCODE_TV_INPUT_HDMI_1`)1270TVInputHDMI1,1271/// Switch to HDMI input #2. (`KEYCODE_TV_INPUT_HDMI_2`)1272TVInputHDMI2,1273/// Switch to HDMI input #3. (`KEYCODE_TV_INPUT_HDMI_3`)1274TVInputHDMI3,1275/// Switch to HDMI input #4. (`KEYCODE_TV_INPUT_HDMI_4`)1276TVInputHDMI4,1277/// Switch to VGA input #1. (`KEYCODE_TV_INPUT_VGA_1`)1278TVInputVGA1,1279/// Media context menu. (`KEYCODE_TV_MEDIA_CONTEXT_MENU`)1280TVMediaContext,1281/// Toggle network. (`KEYCODE_TV_NETWORK`)1282TVNetwork,1283/// Number entry. (`KEYCODE_TV_NUMBER_ENTRY`)1284TVNumberEntry,1285/// Toggle the power on an external TV. (`KEYCODE_TV_POWER`)1286TVPower,1287/// Radio. (`KEYCODE_TV_RADIO_SERVICE`)1288TVRadioService,1289/// Satellite. (`KEYCODE_TV_SATELLITE`)1290TVSatellite,1291/// Broadcast Satellite. (`KEYCODE_TV_SATELLITE_BS`)1292TVSatelliteBS,1293/// Communication Satellite. (`KEYCODE_TV_SATELLITE_CS`)1294TVSatelliteCS,1295/// Toggle between available satellites. (`KEYCODE_TV_SATELLITE_SERVICE`)1296TVSatelliteToggle,1297/// Analog Terrestrial. (`KEYCODE_TV_TERRESTRIAL_ANALOG`)1298TVTerrestrialAnalog,1299/// Digital Terrestrial. (`KEYCODE_TV_TERRESTRIAL_DIGITAL`)1300TVTerrestrialDigital,1301/// Timer programming. (`KEYCODE_TV_TIMER_PROGRAMMING`)1302TVTimer,1303/// Switch the input mode on an external AVR (audio/video receiver). (`KEYCODE_AVR_INPUT`)1304AVRInput,1305/// Toggle the power on an external AVR (audio/video receiver). (`KEYCODE_AVR_POWER`)1306AVRPower,1307/// General purpose color-coded media function key, as index 0 (red). (`VK_COLORED_KEY_0`,1308/// `KEYCODE_PROG_RED`)1309ColorF0Red,1310/// General purpose color-coded media function key, as index 1 (green). (`VK_COLORED_KEY_1`,1311/// `KEYCODE_PROG_GREEN`)1312ColorF1Green,1313/// General purpose color-coded media function key, as index 2 (yellow). (`VK_COLORED_KEY_2`,1314/// `KEYCODE_PROG_YELLOW`)1315ColorF2Yellow,1316/// General purpose color-coded media function key, as index 3 (blue). (`VK_COLORED_KEY_3`,1317/// `KEYCODE_PROG_BLUE`)1318ColorF3Blue,1319/// General purpose color-coded media function key, as index 4 (grey). (`VK_COLORED_KEY_4`)1320ColorF4Grey,1321/// General purpose color-coded media function key, as index 5 (brown). (`VK_COLORED_KEY_5`)1322ColorF5Brown,1323/// Toggle the display of Closed Captions. (`VK_CC`, `KEYCODE_CAPTIONS`)1324ClosedCaptionToggle,1325/// Adjust brightness of device, by toggling between or cycling through states. (`VK_DIMMER`)1326Dimmer,1327/// Swap video sources. (`VK_DISPLAY_SWAP`)1328DisplaySwap,1329/// Select Digital Video Recorder. (`KEYCODE_DVR`)1330DVR,1331/// Exit the current application. (`VK_EXIT`)1332Exit,1333/// Clear program or content stored as favorite 0. (`VK_CLEAR_FAVORITE_0`)1334FavoriteClear0,1335/// Clear program or content stored as favorite 1. (`VK_CLEAR_FAVORITE_1`)1336FavoriteClear1,1337/// Clear program or content stored as favorite 2. (`VK_CLEAR_FAVORITE_2`)1338FavoriteClear2,1339/// Clear program or content stored as favorite 3. (`VK_CLEAR_FAVORITE_3`)1340FavoriteClear3,1341/// Select (recall) program or content stored as favorite 0. (`VK_RECALL_FAVORITE_0`)1342FavoriteRecall0,1343/// Select (recall) program or content stored as favorite 1. (`VK_RECALL_FAVORITE_1`)1344FavoriteRecall1,1345/// Select (recall) program or content stored as favorite 2. (`VK_RECALL_FAVORITE_2`)1346FavoriteRecall2,1347/// Select (recall) program or content stored as favorite 3. (`VK_RECALL_FAVORITE_3`)1348FavoriteRecall3,1349/// Store current program or content as favorite 0. (`VK_STORE_FAVORITE_0`)1350FavoriteStore0,1351/// Store current program or content as favorite 1. (`VK_STORE_FAVORITE_1`)1352FavoriteStore1,1353/// Store current program or content as favorite 2. (`VK_STORE_FAVORITE_2`)1354FavoriteStore2,1355/// Store current program or content as favorite 3. (`VK_STORE_FAVORITE_3`)1356FavoriteStore3,1357/// Toggle display of program or content guide. (`VK_GUIDE`, `KEYCODE_GUIDE`)1358Guide,1359/// If guide is active and displayed, then display next day’s content. (`VK_NEXT_DAY`)1360GuideNextDay,1361/// If guide is active and displayed, then display previous day’s content. (`VK_PREV_DAY`)1362GuidePreviousDay,1363/// Toggle display of information about currently selected context or media. (`VK_INFO`,1364/// `KEYCODE_INFO`)1365Info,1366/// Toggle instant replay. (`VK_INSTANT_REPLAY`)1367InstantReplay,1368/// Launch linked content, if available and appropriate. (`VK_LINK`)1369Link,1370/// List the current program. (`VK_LIST`)1371ListProgram,1372/// Toggle display listing of currently available live content or programs. (`VK_LIVE`)1373LiveContent,1374/// Lock or unlock current content or program. (`VK_LOCK`)1375Lock,1376/// Show a list of media applications: audio/video players and image viewers. (`VK_APPS`)1377///1378/// Note: Do not confuse this key value with the Windows' `VK_APPS` / `VK_CONTEXT_MENU` key,1379/// which is encoded as `"ContextMenu"`.1380MediaApps,1381/// Audio track key. (`KEYCODE_MEDIA_AUDIO_TRACK`)1382MediaAudioTrack,1383/// Select previously selected channel or media. (`VK_LAST`, `KEYCODE_LAST_CHANNEL`)1384MediaLast,1385/// Skip backward to next content or program. (`KEYCODE_MEDIA_SKIP_BACKWARD`)1386MediaSkipBackward,1387/// Skip forward to next content or program. (`VK_SKIP`, `KEYCODE_MEDIA_SKIP_FORWARD`)1388MediaSkipForward,1389/// Step backward to next content or program. (`KEYCODE_MEDIA_STEP_BACKWARD`)1390MediaStepBackward,1391/// Step forward to next content or program. (`KEYCODE_MEDIA_STEP_FORWARD`)1392MediaStepForward,1393/// Media top menu. (`KEYCODE_MEDIA_TOP_MENU`)1394MediaTopMenu,1395/// Navigate in. (`KEYCODE_NAVIGATE_IN`)1396NavigateIn,1397/// Navigate to next key. (`KEYCODE_NAVIGATE_NEXT`)1398NavigateNext,1399/// Navigate out. (`KEYCODE_NAVIGATE_OUT`)1400NavigateOut,1401/// Navigate to previous key. (`KEYCODE_NAVIGATE_PREVIOUS`)1402NavigatePrevious,1403/// Cycle to next favorite channel (in favorites list). (`VK_NEXT_FAVORITE_CHANNEL`)1404NextFavoriteChannel,1405/// Cycle to next user profile (if there are multiple user profiles). (`VK_USER`)1406NextUserProfile,1407/// Access on-demand content or programs. (`VK_ON_DEMAND`)1408OnDemand,1409/// Pairing key to pair devices. (`KEYCODE_PAIRING`)1410Pairing,1411/// Move picture-in-picture window down. (`VK_PINP_DOWN`)1412PinPDown,1413/// Move picture-in-picture window. (`VK_PINP_MOVE`)1414PinPMove,1415/// Toggle display of picture-in-picture window. (`VK_PINP_TOGGLE`)1416PinPToggle,1417/// Move picture-in-picture window up. (`VK_PINP_UP`)1418PinPUp,1419/// Decrease media playback speed. (`VK_PLAY_SPEED_DOWN`)1420PlaySpeedDown,1421/// Reset playback to normal speed. (`VK_PLAY_SPEED_RESET`)1422PlaySpeedReset,1423/// Increase media playback speed. (`VK_PLAY_SPEED_UP`)1424PlaySpeedUp,1425/// Toggle random media or content shuffle mode. (`VK_RANDOM_TOGGLE`)1426RandomToggle,1427/// Not a physical key, but this key code is sent when the remote control battery is low.1428/// (`VK_RC_LOW_BATTERY`)1429RcLowBattery,1430/// Toggle or cycle between media recording speeds. (`VK_RECORD_SPEED_NEXT`)1431RecordSpeedNext,1432/// Toggle RF (radio frequency) input bypass mode (pass RF input directly to the RF output).1433/// (`VK_RF_BYPASS`)1434RfBypass,1435/// Toggle scan channels mode. (`VK_SCAN_CHANNELS_TOGGLE`)1436ScanChannelsToggle,1437/// Advance display screen mode to next available mode. (`VK_SCREEN_MODE_NEXT`)1438ScreenModeNext,1439/// Toggle display of device settings screen. (`VK_SETTINGS`, `KEYCODE_SETTINGS`)1440Settings,1441/// Toggle split screen mode. (`VK_SPLIT_SCREEN_TOGGLE`)1442SplitScreenToggle,1443/// Switch the input mode on an external STB (set top box). (`KEYCODE_STB_INPUT`)1444STBInput,1445/// Toggle the power on an external STB (set top box). (`KEYCODE_STB_POWER`)1446STBPower,1447/// Toggle display of subtitles, if available. (`VK_SUBTITLE`)1448Subtitle,1449/// Toggle display of teletext, if available (`VK_TELETEXT`, `KEYCODE_TV_TELETEXT`).1450Teletext,1451/// Advance video mode to next available mode. (`VK_VIDEO_MODE_NEXT`)1452VideoModeNext,1453/// Cause device to identify itself in some manner, e.g., audibly or visibly. (`VK_WINK`)1454Wink,1455/// Toggle between full-screen and scaled content, or alter magnification level. (`VK_ZOOM`,1456/// `KEYCODE_TV_ZOOM_MODE`)1457ZoomToggle,1458/// General-purpose function key.1459/// Usually found at the top of the keyboard.1460F1,1461/// General-purpose function key.1462/// Usually found at the top of the keyboard.1463F2,1464/// General-purpose function key.1465/// Usually found at the top of the keyboard.1466F3,1467/// General-purpose function key.1468/// Usually found at the top of the keyboard.1469F4,1470/// General-purpose function key.1471/// Usually found at the top of the keyboard.1472F5,1473/// General-purpose function key.1474/// Usually found at the top of the keyboard.1475F6,1476/// General-purpose function key.1477/// Usually found at the top of the keyboard.1478F7,1479/// General-purpose function key.1480/// Usually found at the top of the keyboard.1481F8,1482/// General-purpose function key.1483/// Usually found at the top of the keyboard.1484F9,1485/// General-purpose function key.1486/// Usually found at the top of the keyboard.1487F10,1488/// General-purpose function key.1489/// Usually found at the top of the keyboard.1490F11,1491/// General-purpose function key.1492/// Usually found at the top of the keyboard.1493F12,1494/// General-purpose function key.1495/// Usually found at the top of the keyboard.1496F13,1497/// General-purpose function key.1498/// Usually found at the top of the keyboard.1499F14,1500/// General-purpose function key.1501/// Usually found at the top of the keyboard.1502F15,1503/// General-purpose function key.1504/// Usually found at the top of the keyboard.1505F16,1506/// General-purpose function key.1507/// Usually found at the top of the keyboard.1508F17,1509/// General-purpose function key.1510/// Usually found at the top of the keyboard.1511F18,1512/// General-purpose function key.1513/// Usually found at the top of the keyboard.1514F19,1515/// General-purpose function key.1516/// Usually found at the top of the keyboard.1517F20,1518/// General-purpose function key.1519/// Usually found at the top of the keyboard.1520F21,1521/// General-purpose function key.1522/// Usually found at the top of the keyboard.1523F22,1524/// General-purpose function key.1525/// Usually found at the top of the keyboard.1526F23,1527/// General-purpose function key.1528/// Usually found at the top of the keyboard.1529F24,1530/// General-purpose function key.1531F25,1532/// General-purpose function key.1533F26,1534/// General-purpose function key.1535F27,1536/// General-purpose function key.1537F28,1538/// General-purpose function key.1539F29,1540/// General-purpose function key.1541F30,1542/// General-purpose function key.1543F31,1544/// General-purpose function key.1545F32,1546/// General-purpose function key.1547F33,1548/// General-purpose function key.1549F34,1550/// General-purpose function key.1551F35,1552}155315541555