2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #import "PlatformKeyboardEvent.h"
30 #import <Carbon/Carbon.h>
31 #import <wtf/ASCIICType.h>
37 static String keyIdentifierForKeyEvent(NSEvent* event)
39 if ([event type] == NSFlagsChanged)
40 switch ([event keyCode]) {
41 case 54: // Right Command
42 case 55: // Left Command
48 case 56: // Left Shift
49 case 60: // Right Shift
57 case 62: // Right Ctrl
65 NSString *s = [event charactersIgnoringModifiers];
66 if ([s length] != 1) {
67 LOG(Events, "received an unexpected number of characters in key event: %u", [s length]);
68 return "Unidentified";
70 unichar c = [s characterAtIndex:0];
72 // Each identifier listed in the DOM spec is listed here.
73 // Many are simply commented out since they do not appear on standard Macintosh keyboards
74 // or are on a key that doesn't have a corresponding character.
80 case NSMenuFunctionKey:
93 case NSClearLineFunctionKey:
105 case NSDownArrowFunctionKey:
108 case NSEndFunctionKey:
111 case 0x3: case 0xA: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
117 case NSExecuteFunctionKey:
123 case NSF1FunctionKey:
126 case NSF2FunctionKey:
129 case NSF3FunctionKey:
132 case NSF4FunctionKey:
135 case NSF5FunctionKey:
138 case NSF6FunctionKey:
141 case NSF7FunctionKey:
144 case NSF8FunctionKey:
147 case NSF9FunctionKey:
150 case NSF10FunctionKey:
153 case NSF11FunctionKey:
156 case NSF12FunctionKey:
159 case NSF13FunctionKey:
162 case NSF14FunctionKey:
165 case NSF15FunctionKey:
168 case NSF16FunctionKey:
171 case NSF17FunctionKey:
174 case NSF18FunctionKey:
177 case NSF19FunctionKey:
180 case NSF20FunctionKey:
183 case NSF21FunctionKey:
186 case NSF22FunctionKey:
189 case NSF23FunctionKey:
192 case NSF24FunctionKey:
198 case NSFindFunctionKey:
207 case NSHelpFunctionKey:
213 case NSHomeFunctionKey:
216 case NSInsertFunctionKey:
219 // "JapaneseHiragana"
220 // "JapaneseKatakana"
226 // "LaunchApplication1"
227 // "LaunchApplication2"
231 case NSLeftArrowFunctionKey:
237 // "MediaPreviousTrack"
241 case NSModeSwitchFunctionKey:
248 case NSPageDownFunctionKey:
251 case NSPageUpFunctionKey:
257 case NSPauseFunctionKey:
261 // "PreviousCandidate"
264 case NSPrintScreenFunctionKey:
265 return "PrintScreen";
271 case NSRightArrowFunctionKey:
277 case NSScrollLockFunctionKey:
280 case NSSelectFunctionKey:
287 case NSStopFunctionKey:
290 case NSUpArrowFunctionKey:
293 case NSUndoFunctionKey:
302 // More function keys, not in the key identifier specification.
303 case NSF25FunctionKey:
305 case NSF26FunctionKey:
307 case NSF27FunctionKey:
309 case NSF28FunctionKey:
311 case NSF29FunctionKey:
313 case NSF30FunctionKey:
315 case NSF31FunctionKey:
317 case NSF32FunctionKey:
319 case NSF33FunctionKey:
321 case NSF34FunctionKey:
323 case NSF35FunctionKey:
326 // Turn 0x7F into 0x08, because backspace needs to always be 0x08.
329 // Standard says that DEL becomes U+007F.
330 case NSDeleteFunctionKey:
333 // Always use 0x09 for tab instead of AppKit's backtab character.
334 case NSBackTabCharacter:
337 case NSBeginFunctionKey:
338 case NSBreakFunctionKey:
339 case NSClearDisplayFunctionKey:
340 case NSDeleteCharFunctionKey:
341 case NSDeleteLineFunctionKey:
342 case NSInsertCharFunctionKey:
343 case NSInsertLineFunctionKey:
344 case NSNextFunctionKey:
345 case NSPrevFunctionKey:
346 case NSPrintFunctionKey:
347 case NSRedoFunctionKey:
348 case NSResetFunctionKey:
349 case NSSysReqFunctionKey:
350 case NSSystemFunctionKey:
351 case NSUserFunctionKey:
352 // FIXME: We should use something other than the vendor-area Unicode values for the above keys.
353 // For now, just fall through to the default.
355 return String::format("U+%04X", toASCIIUpper(c));
359 static bool isKeypadEvent(NSEvent* event)
361 // Check that this is the type of event that has a keyCode.
362 switch ([event type]) {
371 switch ([event keyCode]) {
396 static int windowsKeyCodeForKeyEvent(NSEvent* event)
398 switch ([event keyCode]) {
399 // VK_TAB (09) TAB key
400 case 48: return 0x09;
402 // VK_APPS (5D) Right windows/meta key
403 case 54: // Right Command
406 // VK_LWIN (5B) Left windows/meta key
407 case 55: // Left Command
410 // VK_CAPITAL (14) caps locks key
414 // VK_SHIFT (10) either shift key
415 case 56: // Left Shift
416 case 60: // Right Shift
419 // VK_MENU (12) either alt key
421 case 61: // Right Alt
424 // VK_CONTROL (11) either ctrl key
425 case 59: // Left Ctrl
426 case 62: // Right Ctrl
429 // VK_CLEAR (0C) CLEAR key
430 case 71: return 0x0C;
432 // VK_NUMPAD0 (60) Numeric keypad 0 key
433 case 82: return 0x60;
434 // VK_NUMPAD1 (61) Numeric keypad 1 key
435 case 83: return 0x61;
436 // VK_NUMPAD2 (62) Numeric keypad 2 key
437 case 84: return 0x62;
438 // VK_NUMPAD3 (63) Numeric keypad 3 key
439 case 85: return 0x63;
440 // VK_NUMPAD4 (64) Numeric keypad 4 key
441 case 86: return 0x64;
442 // VK_NUMPAD5 (65) Numeric keypad 5 key
443 case 87: return 0x65;
444 // VK_NUMPAD6 (66) Numeric keypad 6 key
445 case 88: return 0x66;
446 // VK_NUMPAD7 (67) Numeric keypad 7 key
447 case 89: return 0x67;
448 // VK_NUMPAD8 (68) Numeric keypad 8 key
449 case 91: return 0x68;
450 // VK_NUMPAD9 (69) Numeric keypad 9 key
451 case 92: return 0x69;
452 // VK_MULTIPLY (6A) Multiply key
453 case 67: return 0x6A;
454 // VK_ADD (6B) Add key
455 case 69: return 0x6B;
457 // VK_SUBTRACT (6D) Subtract key
458 case 78: return 0x6D;
459 // VK_DECIMAL (6E) Decimal key
460 case 65: return 0x6E;
461 // VK_DIVIDE (6F) Divide key
462 case 75: return 0x6F;
465 NSString* s = [event charactersIgnoringModifiers];
469 switch ([s characterAtIndex:0]) {
470 // VK_LBUTTON (01) Left mouse button
471 // VK_RBUTTON (02) Right mouse button
472 // VK_CANCEL (03) Control-break processing
473 // VK_MBUTTON (04) Middle mouse button (three-button mouse)
477 // VK_BACK (08) BACKSPACE key
478 case 8: case 0x7F: return 0x08;
479 // VK_TAB (09) TAB key
482 // VK_CLEAR (0C) CLEAR key
483 // handled by key code above
486 case 0xD: case 3: return 0x0D;
488 // VK_SHIFT (10) SHIFT key
489 // VK_CONTROL (11) CTRL key
490 // VK_MENU (12) ALT key
492 // VK_PAUSE (13) PAUSE key
493 case NSPauseFunctionKey: return 0x13;
495 // VK_CAPITAL (14) CAPS LOCK key
496 // VK_KANA (15) Input Method Editor (IME) Kana mode
497 // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
498 // VK_HANGUL (15) IME Hangul mode
499 // VK_JUNJA (17) IME Junja mode
500 // VK_FINAL (18) IME final mode
501 // VK_HANJA (19) IME Hanja mode
502 // VK_KANJI (19) IME Kanji mode
504 // VK_ESCAPE (1B) ESC key
505 case 0x1B: return 0x1B;
507 // VK_CONVERT (1C) IME convert
508 // VK_NONCONVERT (1D) IME nonconvert
509 // VK_ACCEPT (1E) IME accept
510 // VK_MODECHANGE (1F) IME mode change request
512 // VK_SPACE (20) SPACEBAR
513 case ' ': return 0x20;
514 // VK_PRIOR (21) PAGE UP key
515 case NSPageUpFunctionKey: return 0x21;
516 // VK_NEXT (22) PAGE DOWN key
517 case NSPageDownFunctionKey: return 0x22;
518 // VK_END (23) END key
519 case NSEndFunctionKey: return 0x23;
520 // VK_HOME (24) HOME key
521 case NSHomeFunctionKey: return 0x24;
522 // VK_LEFT (25) LEFT ARROW key
523 case NSLeftArrowFunctionKey: return 0x25;
524 // VK_UP (26) UP ARROW key
525 case NSUpArrowFunctionKey: return 0x26;
526 // VK_RIGHT (27) RIGHT ARROW key
527 case NSRightArrowFunctionKey: return 0x27;
528 // VK_DOWN (28) DOWN ARROW key
529 case NSDownArrowFunctionKey: return 0x28;
530 // VK_SELECT (29) SELECT key
531 case NSSelectFunctionKey: return 0x29;
532 // VK_PRINT (2A) PRINT key
533 case NSPrintFunctionKey: return 0x2A;
534 // VK_EXECUTE (2B) EXECUTE key
535 case NSExecuteFunctionKey: return 0x2B;
536 // VK_SNAPSHOT (2C) PRINT SCREEN key
537 case NSPrintScreenFunctionKey: return 0x2C;
538 // VK_INSERT (2D) INS key
539 case NSInsertFunctionKey: case NSHelpFunctionKey: return 0x2D;
540 // VK_DELETE (2E) DEL key
541 case NSDeleteFunctionKey: return 0x2E;
543 // VK_HELP (2F) HELP key
546 case '0': case ')': return 0x30;
548 case '1': case '!': return 0x31;
550 case '2': case '@': return 0x32;
552 case '3': case '#': return 0x33;
554 case '4': case '$': return 0x34;
556 case '5': case '%': return 0x35;
558 case '6': case '^': return 0x36;
560 case '7': case '&': return 0x37;
562 case '8': case '*': return 0x38;
564 case '9': case '(': return 0x39;
566 case 'a': case 'A': return 0x41;
568 case 'b': case 'B': return 0x42;
570 case 'c': case 'C': return 0x43;
572 case 'd': case 'D': return 0x44;
574 case 'e': case 'E': return 0x45;
576 case 'f': case 'F': return 0x46;
578 case 'g': case 'G': return 0x47;
580 case 'h': case 'H': return 0x48;
582 case 'i': case 'I': return 0x49;
584 case 'j': case 'J': return 0x4A;
586 case 'k': case 'K': return 0x4B;
588 case 'l': case 'L': return 0x4C;
590 case 'm': case 'M': return 0x4D;
592 case 'n': case 'N': return 0x4E;
594 case 'o': case 'O': return 0x4F;
596 case 'p': case 'P': return 0x50;
598 case 'q': case 'Q': return 0x51;
600 case 'r': case 'R': return 0x52;
602 case 's': case 'S': return 0x53;
604 case 't': case 'T': return 0x54;
606 case 'u': case 'U': return 0x55;
608 case 'v': case 'V': return 0x56;
610 case 'w': case 'W': return 0x57;
612 case 'x': case 'X': return 0x58;
614 case 'y': case 'Y': return 0x59;
616 case 'z': case 'Z': return 0x5A;
618 // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
619 // VK_RWIN (5C) Right Windows key (Natural keyboard)
620 // VK_APPS (5D) Applications key (Natural keyboard)
621 // VK_SLEEP (5F) Computer Sleep key
623 // VK_NUMPAD0 (60) Numeric keypad 0 key
624 // VK_NUMPAD1 (61) Numeric keypad 1 key
625 // VK_NUMPAD2 (62) Numeric keypad 2 key
626 // VK_NUMPAD3 (63) Numeric keypad 3 key
627 // VK_NUMPAD4 (64) Numeric keypad 4 key
628 // VK_NUMPAD5 (65) Numeric keypad 5 key
629 // VK_NUMPAD6 (66) Numeric keypad 6 key
630 // VK_NUMPAD7 (67) Numeric keypad 7 key
631 // VK_NUMPAD8 (68) Numeric keypad 8 key
632 // VK_NUMPAD9 (69) Numeric keypad 9 key
633 // VK_MULTIPLY (6A) Multiply key
634 // VK_ADD (6B) Add key
635 // handled by key code above
637 // VK_SEPARATOR (6C) Separator key
639 // VK_SUBTRACT (6D) Subtract key
640 // VK_DECIMAL (6E) Decimal key
641 // VK_DIVIDE (6F) Divide key
642 // handled by key code above
645 case NSF1FunctionKey: return 0x70;
647 case NSF2FunctionKey: return 0x71;
649 case NSF3FunctionKey: return 0x72;
651 case NSF4FunctionKey: return 0x73;
653 case NSF5FunctionKey: return 0x74;
655 case NSF6FunctionKey: return 0x75;
657 case NSF7FunctionKey: return 0x76;
659 case NSF8FunctionKey: return 0x77;
661 case NSF9FunctionKey: return 0x78;
662 // VK_F10 (79) F10 key
663 case NSF10FunctionKey: return 0x79;
664 // VK_F11 (7A) F11 key
665 case NSF11FunctionKey: return 0x7A;
666 // VK_F12 (7B) F12 key
667 case NSF12FunctionKey: return 0x7B;
668 // VK_F13 (7C) F13 key
669 case NSF13FunctionKey: return 0x7C;
670 // VK_F14 (7D) F14 key
671 case NSF14FunctionKey: return 0x7D;
672 // VK_F15 (7E) F15 key
673 case NSF15FunctionKey: return 0x7E;
674 // VK_F16 (7F) F16 key
675 case NSF16FunctionKey: return 0x7F;
676 // VK_F17 (80H) F17 key
677 case NSF17FunctionKey: return 0x80;
678 // VK_F18 (81H) F18 key
679 case NSF18FunctionKey: return 0x81;
680 // VK_F19 (82H) F19 key
681 case NSF19FunctionKey: return 0x82;
682 // VK_F20 (83H) F20 key
683 case NSF20FunctionKey: return 0x83;
684 // VK_F21 (84H) F21 key
685 case NSF21FunctionKey: return 0x84;
686 // VK_F22 (85H) F22 key
687 case NSF22FunctionKey: return 0x85;
688 // VK_F23 (86H) F23 key
689 case NSF23FunctionKey: return 0x86;
690 // VK_F24 (87H) F24 key
691 case NSF24FunctionKey: return 0x87;
693 // VK_NUMLOCK (90) NUM LOCK key
695 // VK_SCROLL (91) SCROLL LOCK key
696 case NSScrollLockFunctionKey: return 0x91;
698 // VK_LSHIFT (A0) Left SHIFT key
699 // VK_RSHIFT (A1) Right SHIFT key
700 // VK_LCONTROL (A2) Left CONTROL key
701 // VK_RCONTROL (A3) Right CONTROL key
702 // VK_LMENU (A4) Left MENU key
703 // VK_RMENU (A5) Right MENU key
704 // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
705 // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
706 // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
707 // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
708 // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
709 // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
710 // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
711 // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
712 // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
713 // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
714 // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
715 // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
716 // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
717 // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
718 // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
719 // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
720 // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
721 // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
723 // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
724 case ';': case ':': return 0xBA;
725 // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
726 case '=': case '+': return 0xBB;
727 // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
728 case ',': case '<': return 0xBC;
729 // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
730 case '-': case '_': return 0xBD;
731 // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
732 case '.': case '>': return 0xBE;
733 // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
734 case '/': case '?': return 0xBF;
735 // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
736 case '`': case '~': return 0xC0;
737 // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
738 case '[': case '{': return 0xDB;
739 // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
740 case '\\': case '|': return 0xDC;
741 // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
742 case ']': case '}': return 0xDD;
743 // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
744 case '\'': case '"': return 0xDE;
746 // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
747 // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
748 // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
749 // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
750 // VK_ATTN (F6) Attn key
751 // VK_CRSEL (F7) CrSel key
752 // VK_EXSEL (F8) ExSel key
753 // VK_EREOF (F9) Erase EOF key
754 // VK_PLAY (FA) Play key
755 // VK_ZOOM (FB) Zoom key
756 // VK_NONAME (FC) Reserved for future use
757 // VK_PA1 (FD) PA1 key
758 // VK_OEM_CLEAR (FE) Clear key
764 static inline bool isKeyUpEvent(NSEvent *event)
766 if ([event type] != NSFlagsChanged)
767 return [event type] == NSKeyUp;
768 // FIXME: This logic fails if the user presses both Shift keys at once, for example:
769 // we treat releasing one of them as keyDown.
770 switch ([event keyCode]) {
771 case 54: // Right Command
772 case 55: // Left Command
773 return ([event modifierFlags] & NSCommandKeyMask) == 0;
776 return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0;
778 case 56: // Left Shift
779 case 60: // Right Shift
780 return ([event modifierFlags] & NSShiftKeyMask) == 0;
783 case 61: // Right Alt
784 return ([event modifierFlags] & NSAlternateKeyMask) == 0;
786 case 59: // Left Ctrl
787 case 62: // Right Ctrl
788 return ([event modifierFlags] & NSControlKeyMask) == 0;
791 return ([event modifierFlags] & NSFunctionKeyMask) == 0;
796 static inline String textFromEvent(NSEvent* event)
798 if ([event type] == NSFlagsChanged)
800 return [event characters];
804 static inline String unmodifiedTextFromEvent(NSEvent* event)
806 if ([event type] == NSFlagsChanged)
808 return [event charactersIgnoringModifiers];
811 PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event)
812 : m_type(isKeyUpEvent(event) ? PlatformKeyboardEvent::KeyUp : PlatformKeyboardEvent::KeyDown)
813 , m_text(textFromEvent(event))
814 , m_unmodifiedText(unmodifiedTextFromEvent(event))
815 , m_keyIdentifier(keyIdentifierForKeyEvent(event))
816 , m_autoRepeat(([event type] != NSFlagsChanged) && [event isARepeat])
817 , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event))
818 , m_isKeypad(isKeypadEvent(event))
819 , m_shiftKey([event modifierFlags] & NSShiftKeyMask)
820 , m_ctrlKey([event modifierFlags] & NSControlKeyMask)
821 , m_altKey([event modifierFlags] & NSAlternateKeyMask)
822 , m_metaKey([event modifierFlags] & NSCommandKeyMask)
825 // Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter.
826 if (m_windowsVirtualKeyCode == '\r') {
828 m_unmodifiedText = "\r";
831 // The adjustments below are only needed in backward compatibility mode, but we cannot tell what mode we are in from here.
833 // Turn 0x7F into 8, because backspace needs to always be 8.
834 if (m_text == "\x7F")
836 if (m_unmodifiedText == "\x7F")
837 m_unmodifiedText = "\x8";
838 // Always use 9 for tab -- we don't want to use AppKit's different character for shift-tab.
839 if (m_windowsVirtualKeyCode == 9) {
841 m_unmodifiedText = "\x9";
845 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
847 // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
848 ASSERT(m_type == KeyDown);
849 ASSERT(type == RawKeyDown || type == Char);
851 if (backwardCompatibilityMode)
854 if (type == RawKeyDown) {
856 m_unmodifiedText = String();
858 m_keyIdentifier = String();
859 m_windowsVirtualKeyCode = 0;
863 bool PlatformKeyboardEvent::currentCapsLockState()
865 return GetCurrentKeyModifiers() & alphaLock;