From a37d396577b7ee39e6945334b9cd8f44367a3a69 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 12 Feb 2013 19:04:43 +0000 Subject: [PATCH] fix issue where opera was doing stupid things but still an issue w/ double tabs exists --- src/static/js/ace2_inner.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index c48be1bc..8209c9bf 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3561,6 +3561,11 @@ function Ace2Inner(){ var isModKey = ((!charCode) && ((type == "keyup") || (type == "keydown")) && (keyCode == 16 || keyCode == 17 || keyCode == 18 || keyCode == 20 || keyCode == 224 || keyCode == 91)); if (isModKey) return; + // If the key is a keypress and the browser is opera and the key is enter, do nothign at all as this fires twice. + if (keyCode == 13 && browser.opera && (type == "keypress")){ + return; // This stops double enters in Opera but double Tabs still show on single tab keypress, adding keyCode == 9 to this doesn't help as the event is fired twice + } + var specialHandled = false; var isTypeForSpecialKey = ((browser.msie || browser.safari) ? (type == "keydown") : (type == "keypress")); var isTypeForCmdKey = ((browser.msie || browser.safari) ? (type == "keydown") : (type == "keypress")); @@ -4651,10 +4656,7 @@ function Ace2Inner(){ function bindTheEventHandlers() { $(document).on("keydown", handleKeyEvent); - // Hack for Opera to stop it firing twice on events - if ($.browser.opera){ - $(document).on("keypress", handleKeyEvent); - } + $(document).on("keypress", handleKeyEvent); $(document).on("keyup", handleKeyEvent); $(document).on("click", handleClick); $(root).on("blur", handleBlur);