diff options
Diffstat (limited to 'lib/scripts/edit.js')
-rw-r--r-- | lib/scripts/edit.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index b9767fdc0..b507e804b 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -169,7 +169,7 @@ function keyHandler(e){ var scroll = field.scrollHeight; var match2 = search.match(/^\n +[\*-]\s*$/); // Cancel list if the last item is empty (i. e. two times enter) - if (match2 && field.value.substr(selection.start).match(/^($|\n)/)) { + if (match2 && field.value.substr(selection.start).match(/^($|\r?\n)/)) { field.value = field.value.substr(0, linestart) + "\n" + field.value.substr(selection.start); selection.start = linestart + 1; @@ -222,7 +222,13 @@ function keyHandler(e){ addInitEvent(function(){ var field = $('wiki__text'); if(!field) return; - addEvent(field,'keydown',keyHandler); + // in Firefox, keypress doesn't send the correct keycodes, + // in Opera, the default of keydown can't be prevented + if (is_opera) { + addEvent(field,'keypress',keyHandler); + } else { + addEvent(field,'keydown',keyHandler); + } }); /** |