Make more stuff work
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Fri, 12 Aug 2011 15:16:08 -0600
changeset 525 f7aa32ec50ac
parent 524 7c7f25c5dbb9
child 526 c29980995bb1
Make more stuff work
editor.html
--- a/editor.html	Fri Aug 12 15:01:53 2011 -0600
+++ b/editor.html	Fri Aug 12 15:16:08 2011 -0600
@@ -37,20 +37,26 @@
 	return false;
 }
 document.onkeydown = function(e) {
-	// FIXME: Does not work in Gecko, why not?
+	if (e.keyCode == 8 || e.keyCode == 46) {
+		// Delete, backspace
+		return false;
+	}
+	// Bold/italic/underline.
 	if (e.ctrlKey
-	&& ["b", "u", "i"].indexOf(String.fromCharCode(e.keyCode)) != -1) {
+	&& ["b", "u", "i"].indexOf(String.fromCharCode(e.keyCode).toLowerCase()) != -1) {
 		return false;
 	}
 }
 document.onkeyup = function(e) {
-	if (e.ctrlKey && String.fromCharCode(e.keyCode) == "b") {
+	if (e.keyCode == 8) {
+		myExecCommand("delete");
+	} else if (e.keyCode == 46) {
+		myExecCommand("forwarddelete");
+	} else if (e.ctrlKey && String.fromCharCode(e.keyCode).toLowerCase() == "b") {
 		myExecCommand("bold");
-	}
-	if (e.ctrlKey && String.fromCharCode(e.keyCode) == "i") {
+	} else if (e.ctrlKey && String.fromCharCode(e.keyCode).toLowerCase() == "i") {
 		myExecCommand("italic");
-	}
-	if (e.ctrlKey && String.fromCharCode(e.keyCode) == "u") {
+	} else if (e.ctrlKey && String.fromCharCode(e.keyCode).toLowerCase() == "u") {
 		myExecCommand("underline");
 	}
 }