Inez has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63223


Change subject: (bug 48022) Ignore certain function keys in key press handler
......................................................................

(bug 48022) Ignore certain function keys in key press handler

This is a temporary solution that still may some function keys go through.

Change-Id: I7a8d6c474ecca5af02b72b6453c900ed61acea58
---
M modules/ve/ce/ve.ce.Surface.js
M modules/ve/ve.js
2 files changed, 38 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/23/63223/1

diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 83f28ff..7ad07c5 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -444,12 +444,18 @@
                }
        }
 
-       // FF fire keypress for arrow keys but we handle them in keydown so 
let's ignore
+       // FF fires keypress for bunch of function keys that we want to ignore
        if ( ve.ce.isArrowKey( e.keyCode ) ||
                ve.ce.isShortcutKey( e ) ||
-               e.which === ve.Keys.DOM_VK_RETURN ||
-               e.which === ve.Keys.DOM_VK_BACK_SPACE ||
-               e.which === ve.Keys.DOM_VK_UNDEFINED ) {
+               e.keyCode === 13 ||
+               e.which === ve.Keys.DOM_VK_UNDEFINED ||
+               e.keyCode === ve.Keys.DOM_VK_BACK_SPACE ||
+               e.keyCode === ve.Keys.DOM_VK_END ||
+               e.keyCode === ve.Keys.DOM_VK_ENTER ||
+               e.keyCode === ve.Keys.DOM_VK_HOME ||
+               e.keyCode === ve.Keys.DOM_VK_TAB ||
+               e.keyCode === ve.Keys.DOM_VK_PAGE_DOWN ||
+               e.keyCode === ve.Keys.DOM_VK_PAGE_UP ) {
                return;
        }
        this.handleInsertion();
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index d8783c3..e606403 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -1129,17 +1129,36 @@
 
        // Based on the KeyEvent DOM Level 3 (add more as you need them)
        // 
http://www.w3.org/TR/2001/WD-DOM-Level-3-Events-20010410/DOM3-Events.html#events-Events-KeyEvent
+       // http://www.w3.org/TR/2000/WD-DOM-Level-3-Events-20000901/events.html
        ve.Keys = window.KeyEvent || {
-               'DOM_VK_UNDEFINED': 0,
-               'DOM_VK_BACK_SPACE': 8,
-               'DOM_VK_RETURN': 13,
-               'DOM_VK_LEFT': 37,
-               'DOM_VK_UP': 38,
-               'DOM_VK_RIGHT': 39,
-               'DOM_VK_DOWN': 40,
-               'DOM_VK_DELETE': 46
+               'DOM_VK_UNDEFINED': 0x0,
+               'DOM_VK_RIGHT_ALT': 0x12,
+               'DOM_VK_LEFT_ALT ': 0x12,
+               'DOM_VK_LEFT_CONTROL': 0x11,
+               'DOM_VK_RIGHT_CONTROL': 0x11,
+               'DOM_VK_LEFT_SHIFT': 0x10,
+               'DOM_VK_RIGHT_SHIFT': 0x10,
+               'DOM_VK_META': 0x9D,
+               'DOM_VK_BACK_SPACE': 0x08,
+               'DOM_VK_CAPS_LOCK': 0x14,
+               'DOM_VK_DELETE': 0x7F,
+               'DOM_VK_END': 0x23,
+               'DOM_VK_ENTER': 0x0D,
+               'DOM_VK_ESCAPE': 0x1B,
+               'DOM_VK_HOME': 0x24,
+               'DOM_VK_NUM_LOCK': 0x90,
+               'DOM_VK_PAUSE': 0x13,
+               'DOM_VK_PRINTSCREEN': 0x9A,
+               'DOM_VK_SCROLL_LOCK': 0x91,
+               'DOM_VK_SPACE': 0x20,
+               'DOM_VK_TAB': 0x09,
+               'DOM_VK_LEFT': 0x25,
+               'DOM_VK_RIGHT': 0x27,
+               'DOM_VK_UP': 0x26,
+               'DOM_VK_DOWN': 0x28,
+               'DOM_VK_PAGE_DOWN': 0x22,
+               'DOM_VK_PAGE_UP': 0x21
        };
-
        // Expose
        window.ve = ve;
 }() );

-- 
To view, visit https://gerrit.wikimedia.org/r/63223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a8d6c474ecca5af02b72b6453c900ed61acea58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to