From 5e6423a3684f2053be82f8ca995be30c6ca8a127 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Sun, 24 May 2015 13:49:06 -0400 Subject: [PATCH] add keybindings --- auto.coffee | 9 +++++++++ index.html | 1 + 2 files changed, 10 insertions(+) diff --git a/auto.coffee b/auto.coffee index c4cd5b4..bfd84af 100644 --- a/auto.coffee +++ b/auto.coffee @@ -46,6 +46,13 @@ mousemove = (x, y) -> if selection? update_path selection.element, selection.data, to_mouse: true +keydown = (keycode) -> + switch keycode + when 'O'.charCodeAt 0 + return stop_close_drawing() + when (' '.charCodeAt 0), 13, 10, 27 + return stop_drawing() + # called automatically on domcontentloaded init = -> $container = $ '.crayon_mockup' @@ -70,5 +77,7 @@ init = -> $svg.mousemove (e) -> offset = $svg.offset() mousemove e.pageX - offset.left, e.pageY - offset.top + ($ document).keydown (e) -> + return keydown e.keyCode $ init diff --git a/index.html b/index.html index 1556263..4326c81 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@

Crayon Mockup (working title)

Instructions: click in multiple different places in the box below to draw.

+

Tip: press space to stop drawing, or o to stop and close the loop.

-- 1.7.10.4