diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js
index b9767fdc0f8e551b870af2f3971fa06b31831fae..b507e804b54f204e1533e6d45d09e769b3296e13 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);
+    }
 });
 
 /**
diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js
index 0378b544df7a04f635af9c9609beaf22268448da..742338785e7d2e236a5acf1c85d797dad02ff1bd 100644
--- a/lib/scripts/textselection.js
+++ b/lib/scripts/textselection.js
@@ -161,7 +161,12 @@ function pasteText(selection,text,opts){
         selection.obj.value.substring(selection.end, selection.obj.value.length);
 
     // set new selection
-    selection.end = selection.start + text.length;
+    if (is_opera) {
+        // Opera replaces \n by \r\n when inserting text.
+        selection.end = selection.start + text.replace(/\r?\n/g, '\r\n').length;
+    } else {
+        selection.end = selection.start + text.length;
+    }
 
     // modify the new selection if wanted
     if(opts.startofs) selection.start += opts.startofs;