From 704ae28629154a732e20e16d56b23af265d51b85 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 10 Jan 2015 16:01:40 +0000 Subject: Modes; better printable detection, move to keyboard_utils. --- lib/dom_utils.coffee | 3 --- lib/keyboard_utils.coffee | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index fd2427c4..322188b3 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -212,8 +212,5 @@ DomUtils = @remove() false - isPrintable: (event) -> - not (event.metaKey or event.ctrlKey or event.altKey) - root = exports ? window root.DomUtils = DomUtils diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index d2a843f9..30d99656 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -55,6 +55,12 @@ KeyboardUtils = # c-[ is mapped to ESC in Vim by default. (event.keyCode == @keyCodes.ESC) || (event.ctrlKey && @getKeyChar(event) == '[') + # TODO. This is probably a poor way of detecting printable characters. However, it shouldn't incorrectly + # identify any of chrome's own keyboard shortcuts as printable. + isPrintable: (event) -> + return false if event.metaKey or event.ctrlKey or event.altKey + @getKeyChar(event)?.length == 1 + KeyboardUtils.init() root = exports ? window -- cgit v1.2.3