📄 keyeventgtk.cpp
字号:
/* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2008 Collabora, Ltd. All rights reserved. * 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 "TextEncoding.h"#include <gdk/gdk.h>#include <gdk/gdkkeysyms.h>// GTK_CHECK_VERSION is defined in gtk/gtkversion.h#include <gtk/gtk.h>namespace WebCore {// FIXME: This is incomplete. We should change this to mirror// more like what Firefox does, and generate these switch statements// at build time.static String keyIdentifierForGdkKeyCode(guint keyCode){ switch (keyCode) { case GDK_Menu: case GDK_Alt_L: case GDK_Alt_R: return "Alt"; case GDK_Clear: return "Clear"; case GDK_Down: return "Down"; // "End" case GDK_End: return "End"; // "Enter" case GDK_ISO_Enter: case GDK_KP_Enter: case GDK_Return: return "Enter"; case GDK_Execute: return "Execute"; case GDK_F1: return "F1"; case GDK_F2: return "F2"; case GDK_F3: return "F3"; case GDK_F4: return "F4"; case GDK_F5: return "F5"; case GDK_F6: return "F6"; case GDK_F7: return "F7"; case GDK_F8: return "F8"; case GDK_F9: return "F9"; case GDK_F10: return "F10"; case GDK_F11: return "F11"; case GDK_F12: return "F12"; case GDK_F13: return "F13"; case GDK_F14: return "F14"; case GDK_F15: return "F15"; case GDK_F16: return "F16"; case GDK_F17: return "F17"; case GDK_F18: return "F18"; case GDK_F19: return "F19"; case GDK_F20: return "F20"; case GDK_F21: return "F21"; case GDK_F22: return "F22"; case GDK_F23: return "F23"; case GDK_F24: return "F24"; case GDK_Help: return "Help"; case GDK_Home: return "Home"; case GDK_Insert: return "Insert"; case GDK_Left: return "Left"; case GDK_Page_Down: return "PageDown"; case GDK_Page_Up: return "PageUp"; case GDK_Pause: return "Pause"; case GDK_3270_PrintScreen: return "PrintScreen"; case GDK_Right: return "Right"; case GDK_Select: return "Select"; case GDK_Up: return "Up"; // Standard says that DEL becomes U+007F. case GDK_Delete: return "U+007F"; case GDK_ISO_Left_Tab: case GDK_3270_BackTab: case GDK_Tab: return "U+0009"; default: return String::format("U+%04X", gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode))); }}static int windowsKeyCodeForKeyEvent(unsigned int keycode){ switch (keycode) { case GDK_KP_0: return VK_NUMPAD0;// (60) Numeric keypad 0 key case GDK_KP_1: return VK_NUMPAD1;// (61) Numeric keypad 1 key case GDK_KP_2: return VK_NUMPAD2; // (62) Numeric keypad 2 key case GDK_KP_3: return VK_NUMPAD3; // (63) Numeric keypad 3 key case GDK_KP_4: return VK_NUMPAD4; // (64) Numeric keypad 4 key case GDK_KP_5: return VK_NUMPAD5; //(65) Numeric keypad 5 key case GDK_KP_6: return VK_NUMPAD6; // (66) Numeric keypad 6 key case GDK_KP_7: return VK_NUMPAD7; // (67) Numeric keypad 7 key case GDK_KP_8: return VK_NUMPAD8; // (68) Numeric keypad 8 key case GDK_KP_9: return VK_NUMPAD9; // (69) Numeric keypad 9 key case GDK_KP_Multiply: return VK_MULTIPLY; // (6A) Multiply key case GDK_KP_Add: return VK_ADD; // (6B) Add key case GDK_KP_Subtract: return VK_SUBTRACT; // (6D) Subtract key case GDK_KP_Decimal: return VK_DECIMAL; // (6E) Decimal key case GDK_KP_Divide: return VK_DIVIDE; // (6F) Divide key case GDK_BackSpace: return VK_BACK; // (08) BACKSPACE key case GDK_ISO_Left_Tab: case GDK_3270_BackTab: case GDK_Tab: return VK_TAB; // (09) TAB key case GDK_Clear: return VK_CLEAR; // (0C) CLEAR key case GDK_ISO_Enter: case GDK_KP_Enter: case GDK_Return: return VK_RETURN; //(0D) Return key case GDK_Shift_L: case GDK_Shift_R: return VK_SHIFT; // (10) SHIFT key case GDK_Control_L: case GDK_Control_R: return VK_CONTROL; // (11) CTRL key case GDK_Menu: case GDK_Alt_L: case GDK_Alt_R: return VK_MENU; // (12) ALT key case GDK_Pause: return VK_PAUSE; // (13) PAUSE key case GDK_Caps_Lock: return VK_CAPITAL; // (14) CAPS LOCK key case GDK_Kana_Lock: case GDK_Kana_Shift: return VK_KANA; // (15) Input Method Editor (IME) Kana mode case GDK_Hangul: return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode // VK_JUNJA (17) IME Junja mode // VK_FINAL (18) IME final mode case GDK_Hangul_Hanja: return VK_HANJA; // (19) IME Hanja mode case GDK_Kanji: return VK_KANJI; // (19) IME Kanji mode case GDK_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 case GDK_space: return VK_SPACE; // (20) SPACEBAR case GDK_Page_Up: return VK_PRIOR; // (21) PAGE UP key case GDK_Page_Down: return VK_NEXT; // (22) PAGE DOWN key case GDK_End: return VK_END; // (23) END key case GDK_Home: return VK_HOME; // (24) HOME key case GDK_Left: return VK_LEFT; // (25) LEFT ARROW key case GDK_Up: return VK_UP; // (26) UP ARROW key case GDK_Right: return VK_RIGHT; // (27) RIGHT ARROW key case GDK_Down: return VK_DOWN; // (28) DOWN ARROW key case GDK_Select: return VK_SELECT; // (29) SELECT key case GDK_Print: return VK_PRINT; // (2A) PRINT key case GDK_Execute: return VK_EXECUTE;// (2B) EXECUTE key //dunno on this //case GDK_PrintScreen: // return VK_SNAPSHOT; // (2C) PRINT SCREEN key case GDK_Insert: return VK_INSERT; // (2D) INS key case GDK_Delete: return VK_DELETE; // (2E) DEL key case GDK_Help: return VK_HELP; // (2F) HELP key case GDK_0: case GDK_parenleft: return VK_0; // (30) 0) key case GDK_1: return VK_1; // (31) 1 ! key case GDK_2: case GDK_at: return VK_2; // (32) 2 & key case GDK_3: case GDK_numbersign: return VK_3; //case '3': case '#'; case GDK_4: case GDK_dollar: // (34) 4 key '$'; return VK_4; case GDK_5: case GDK_percent: return VK_5; // (35) 5 key '%' case GDK_6: case GDK_asciicircum: return VK_6; // (36) 6 key '^' case GDK_7: case GDK_ampersand: return VK_7; // (37) 7 key case '&' case GDK_8: case GDK_asterisk: return VK_8; // (38) 8 key '*' case GDK_9: case GDK_parenright: return VK_9; // (39) 9 key '('
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -