@@ -504,33 +504,49 @@ const Events = Module("events", {
504
504
505
505
if ( event . keyCode in this . _code_key )
506
506
key = this . _code_key [ event . keyCode ] ;
507
- }
508
- // [Ctrl-Bug] special handling of mysterious <C-[>, <C-\\>, <C-]>, <C-^>, <C-_> bugs (OS/X)
509
- // (i.e., cntrl codes 27--31)
510
- // ---
511
- // For more information, see:
512
- // [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
513
- // [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
514
- // [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
515
- // https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
516
- // [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
517
- // https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
518
- // ---
519
- //
520
- // The following fixes are only activated if liberator.has("MacUnix").
521
- // Technically, they prevent mappings from <C-Esc> (and
522
- // <C-C-]> if your fancy keyboard permits such things<?>), but
523
- // these <C-control> mappings are probably pathological (<C-Esc>
524
- // certainly is on Windows), and so it is probably
525
- // harmless to remove the has("MacUnix") if desired.
526
- //
527
- else if ( liberator . has ( "MacUnix" ) && event . ctrlKey && charCode >= 27 && charCode <= 31 ) {
528
- if ( charCode == 27 ) { // [Ctrl-Bug 1/5] the <C-[> bug
529
- key = "Esc" ;
530
- modifier = modifier . replace ( "C-" , "" ) ;
507
+
508
+ // [Ctrl-Bug] special handling of mysterious <C-[>, <C-\\>, <C-]>, <C-^>, <C-_> <C--> bugs (OS/X)
509
+ // ---
510
+ // For more information, see:
511
+ // [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
512
+ // [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
513
+ // [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
514
+ // https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
515
+ // [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
516
+ // https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
517
+ // ---
518
+ //
519
+ // The following fixes are only activated if liberator.has("MacUnix").
520
+ // Technically, they prevent mappings from <C-Esc> (and
521
+ // <C-C-]> if your fancy keyboard permits such things<?>), but
522
+ // these <C-control> mappings are probably pathological (<C-Esc>
523
+ // certainly is on Windows), and so it is probably
524
+ // harmless to remove the has("MacUnix") if desired.
525
+
526
+ if ( liberator . has ( "MacUnix" ) && event . ctrlKey ) {
527
+ switch ( event . keyCode ) {
528
+ case 219 : // <C-[>
529
+ key = "Esc" ;
530
+ modifier = modifier . replace ( "C-" , "" ) ;
531
+ break ;
532
+ case 220 : // <C-\\>
533
+ key = "\\" ;
534
+ break ;
535
+ case 221 : // <C-]>
536
+ key = "]" ;
537
+ break ;
538
+ case 173 : // <C-_> and <C-->
539
+ key = event . shiftKey ? "_" : "-" ;
540
+ modifier = modifier . replace ( "S-" , "" ) ;
541
+ break ;
542
+ case 54 : // <C-^>
543
+ key = "^" ;
544
+ modifier = modifier . replace ( "S-" , "" ) ;
545
+ break ;
546
+ default :
547
+ break ;
548
+ }
531
549
}
532
- else // [Ctrl-Bug 2,3,4,5/5] the <C-\\>, <C-]>, <C-^>, <C-_> bugs
533
- key = String . fromCharCode ( charCode + 64 ) ;
534
550
}
535
551
// a normal key like a, b, c, 0, etc.
536
552
else if ( charCode > 0 ) {
0 commit comments