From 1ccf325285c231284a513db5995cde05d85b42a2 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 17 Jun 2011 21:10:15 +0000 Subject: [PATCH] Fix example to work where there is a metaKey but ctrl is used for undo/redo. git-svn-id: http://svn.openlayers.org/trunk/openlayers@12104 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/draw-undo-redo.js | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/examples/draw-undo-redo.js b/examples/draw-undo-redo.js index 74b8ad7d38..73900ab6a7 100644 --- a/examples/draw-undo-redo.js +++ b/examples/draw-undo-redo.js @@ -20,37 +20,26 @@ map.addControl(draw); draw.activate(); OpenLayers.Event.observe(document, "keydown", function(evt) { - var code = evt.keyCode; var handled = false; - if (code === 90) { - // z - if ("metaKey" in evt) { - if (evt.metaKey) { + switch (evt.keyCode) { + case 90: // z + if (evt.metaKey || evt.ctrlKey) { draw.undo(); handled = true; } - } else if (evt.ctrlKey) { - draw.undo(); - handled = true; - } - } - if (code === 89) { - // y - if ("metaKey" in evt) { - if (evt.metaKey) { + break; + case 89: // y + if (evt.metaKey || evt.ctrlKey) { draw.redo(); handled = true; } - } else if (evt.ctrlKey) { - draw.redo(); + break; + case 27: // esc + draw.cancel(); handled = true; - } + break; } if (handled) { OpenLayers.Event.stop(evt); } - if (code === 27) { - // esc - draw.cancel(); - } }); \ No newline at end of file