From 5213a727846c24d73268b29c36db248ed43e2038 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Sat, 29 Nov 2014 00:39:13 +0100 Subject: [PATCH] Implement basic keyboard shortcuts in Firefox --- modules/editor/scripts/editor.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/editor/scripts/editor.js b/modules/editor/scripts/editor.js index bff85c0..bffa49e 100644 --- a/modules/editor/scripts/editor.js +++ b/modules/editor/scripts/editor.js @@ -57,6 +57,22 @@ var mainClosure = function() { }); }); + // Keyboard shortcuts + doc.addEventListener('keypress', function (event) { + if((event.ctrlKey || event.metaKey) && !event.shiftKey) { + if(event.which === 98) { // b + document.execCommand('bold'); + } else if(event.which === 105) { // i + document.execCommand('italic'); + } else if(event.which === 117) { // u + document.execCommand('underline'); + } else { + return; + } + event.preventDefault(); + } + }); + // initialize modules/register handlers // night mode initNight(doc, parentMessageProxy);