From 59302353fb1fb7724b5c64c80fd765fc1dcce8ec Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Nov 2014 17:27:35 -0500 Subject: input eventz --- js/app.js | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'js') diff --git a/js/app.js b/js/app.js index 7bc392b..9c9e994 100644 --- a/js/app.js +++ b/js/app.js @@ -42,40 +42,36 @@ function bind () { cursor_input.focus() }) cursor_input.addEventListener('keydown', function(e){ - if (focused) { focused.key(undefined, e.keyCode) } - }) - cursor_input.addEventListener('input', function(e){ - if (current_tool.name == "shader") { - cursor_input.value = "" - return - } if (! e.metaKey && ! e.ctrlKey && ! e.altKey) { e.preventDefault() } - var char = cursor_input.value - cursor_input.value = "" - - // var charFromKeyCode = String.fromCharCode(e.keyCode) - switch (e.keyCode) { case 27: // esc if (focused) focused.blur() break case 219: // [ - if (! focused && current_tool.name != "text") { - brush.contract(1) - break - } + if (! focused && current_tool.name != "text") { + brush.contract(1) + break + } case 221: // ] - if (! focused && current_tool.name != "text") { - brush.expand(1) - break - } + if (! focused && current_tool.name != "text") { + brush.expand(1) + break + } default: - if (focused) focused.key(char, e.keyCode) - break + if (focused) { focused.key(undefined, e.keyCode) } } }) + cursor_input.addEventListener('input', function(e){ + if (current_tool.name == "shader") { + cursor_input.value = "" + return + } + var char = cursor_input.value + cursor_input.value = "" + if (focused) { focused.key(char, e.keyCode) } + }) var contentType = 'text/plain;charset=utf-8' document.body.addEventListener('copy', function (e) { -- cgit v1.2.3-70-g09d2