📄 platformkeyboardeventqt.cpp
字号:
/* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#include "config.h"#include "PlatformKeyboardEvent.h"#include "KeyboardCodes.h"#include "NotImplemented.h"#include <ctype.h>#include <QKeyEvent>namespace WebCore {static String keyIdentifierForQtKeyCode(int keyCode){ switch (keyCode) { case Qt::Key_Menu: case Qt::Key_Alt: return "Alt"; case Qt::Key_Clear: return "Clear"; case Qt::Key_Down: return "Down"; case Qt::Key_End: return "End"; case Qt::Key_Return: case Qt::Key_Enter: return "Enter";#if QT_VERSION >= 0x040200 case Qt::Key_Execute: return "Execute";#endif case Qt::Key_F1: return "F1"; case Qt::Key_F2: return "F2"; case Qt::Key_F3: return "F3"; case Qt::Key_F4: return "F4"; case Qt::Key_F5: return "F5"; case Qt::Key_F6: return "F6"; case Qt::Key_F7: return "F7"; case Qt::Key_F8: return "F8"; case Qt::Key_F9: return "F9"; case Qt::Key_F10: return "F10"; case Qt::Key_F11: return "F11"; case Qt::Key_F12: return "F12"; case Qt::Key_F13: return "F13"; case Qt::Key_F14: return "F14"; case Qt::Key_F15: return "F15"; case Qt::Key_F16: return "F16"; case Qt::Key_F17: return "F17"; case Qt::Key_F18: return "F18"; case Qt::Key_F19: return "F19"; case Qt::Key_F20: return "F20"; case Qt::Key_F21: return "F21"; case Qt::Key_F22: return "F22"; case Qt::Key_F23: return "F23"; case Qt::Key_F24: return "F24"; case Qt::Key_Help: return "Help"; case Qt::Key_Home: return "Home"; case Qt::Key_Insert: return "Insert"; case Qt::Key_Left: return "Left"; case Qt::Key_PageDown: return "PageDown"; case Qt::Key_PageUp: return "PageUp"; case Qt::Key_Pause: return "Pause"; case Qt::Key_Print: return "PrintScreen"; case Qt::Key_Right: return "Right"; case Qt::Key_Select: return "Select"; case Qt::Key_Up: return "Up"; // Standard says that DEL becomes U+007F. case Qt::Key_Delete: return "U+007F"; case Qt::Key_Tab: return "U+0009"; case Qt::Key_Backtab: return "U+0009"; default: return String::format("U+%04X", toupper(keyCode)); }}static int windowsKeyCodeForKeyEvent(unsigned int keycode){ switch (keycode) { /* FIXME: Need to supply a bool in this func, to determine wheter the event comes from the keypad case Qt::Key_0: return VK_NUMPAD0;// (60) Numeric keypad 0 key case Qt::Key_1: return VK_NUMPAD1;// (61) Numeric keypad 1 key case Qt::Key_2: return VK_NUMPAD2; // (62) Numeric keypad 2 key case Qt::Key_3: return VK_NUMPAD3; // (63) Numeric keypad 3 key case Qt::Key_4: return VK_NUMPAD4; // (64) Numeric keypad 4 key case Qt::Key_5: return VK_NUMPAD5; //(65) Numeric keypad 5 key case Qt::Key_6: return VK_NUMPAD6; // (66) Numeric keypad 6 key case Qt::Key_7: return VK_NUMPAD7; // (67) Numeric keypad 7 key case Qt::Key_8: return VK_NUMPAD8; // (68) Numeric keypad 8 key case Qt::Key_9: return VK_NUMPAD9; // (69) Numeric keypad 9 key case Qt::Key_Asterisk: return VK_MULTIPLY; // (6A) Multiply key case Qt::Key_Plus: return VK_ADD; // (6B) Add key case Qt::Key_Minus: return VK_SUBTRACT; // (6D) Subtract key case Qt::Key_Period: return VK_DECIMAL; // (6E) Decimal key case Qt::Key_Slash: return VK_DIVIDE; // (6F) Divide key */ case Qt::Key_Backspace: return VK_BACK; // (08) BACKSPACE key case Qt::Key_Backtab: case Qt::Key_Tab: return VK_TAB; // (09) TAB key case Qt::Key_Clear: return VK_CLEAR; // (0C) CLEAR key case Qt::Key_Enter: case Qt::Key_Return: return VK_RETURN; //(0D) Return key case Qt::Key_Shift: return VK_SHIFT; // (10) SHIFT key case Qt::Key_Control: return VK_CONTROL; // (11) CTRL key case Qt::Key_Menu: case Qt::Key_Alt: return VK_MENU; // (12) ALT key case Qt::Key_F1: return VK_F1; case Qt::Key_F2: return VK_F2; case Qt::Key_F3: return VK_F3; case Qt::Key_F4: return VK_F4; case Qt::Key_F5: return VK_F5; case Qt::Key_F6: return VK_F6; case Qt::Key_F7: return VK_F7; case Qt::Key_F8: return VK_F8; case Qt::Key_F9: return VK_F9; case Qt::Key_F10: return VK_F11; case Qt::Key_F11: return VK_F11; case Qt::Key_F12: return VK_F12; case Qt::Key_F13: return VK_F13; case Qt::Key_F14: return VK_F14; case Qt::Key_F15: return VK_F15; case Qt::Key_F16: return VK_F16; case Qt::Key_F17: return VK_F17; case Qt::Key_F18: return VK_F18; case Qt::Key_F19: return VK_F19; case Qt::Key_F20: return VK_F20; case Qt::Key_F21: return VK_F21; case Qt::Key_F22: return VK_F22; case Qt::Key_F23: return VK_F23; case Qt::Key_F24: return VK_F24; case Qt::Key_Pause: return VK_PAUSE; // (13) PAUSE key case Qt::Key_CapsLock: return VK_CAPITAL; // (14) CAPS LOCK key case Qt::Key_Kana_Lock: case Qt::Key_Kana_Shift: return VK_KANA; // (15) Input Method Editor (IME) Kana mode case Qt::Key_Hangul: return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode // VK_JUNJA (17) IME Junja mode // VK_FINAL (18) IME final mode case Qt::Key_Hangul_Hanja: return VK_HANJA; // (19) IME Hanja mode case Qt::Key_Kanji: return VK_KANJI; // (19) IME Kanji mode case Qt::Key_Escape: return VK_ESCAPE; // (1B) ESC key // VK_CONVERT (1C) IME convert // VK_NONCONVERT (1D) IME nonconvert // VK_ACCEPT (1E) IME accept // VK_MODECHANGE (1F) IME mode change request
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -