2018-08-28 00:34:17 -04:00
|
|
|
'use strict';
|
|
|
|
|
2018-08-17 17:34:24 -04:00
|
|
|
document.onkeyup = (e) =>
|
|
|
|
{
|
2018-10-01 15:38:14 -04:00
|
|
|
const ch = e.key.toLowerCase();
|
2018-08-17 17:34:24 -04:00
|
|
|
|
2018-09-11 23:27:01 -04:00
|
|
|
if(e.target && e.target.id == "picker_input"){ return; }
|
2018-08-17 17:45:05 -04:00
|
|
|
|
2018-10-10 16:20:44 -04:00
|
|
|
// Output
|
|
|
|
if((e.ctrlKey || e.metaKey) && ch == "s"){ DOTGRID.save(); e.preventDefault(); return; }
|
|
|
|
if((e.ctrlKey || e.metaKey) && ch == "r"){ DOTGRID.render(); e.preventDefault(); return; }
|
|
|
|
if((e.ctrlKey || e.metaKey) && ch == "e"){ DOTGRID.export(); e.preventDefault(); return; }
|
|
|
|
|
2018-10-04 19:52:17 -04:00
|
|
|
if(ch == "backspace" && e.ctrlKey){ DOTGRID.theme.reset(); e.preventDefault(); }
|
2019-01-08 22:49:34 -05:00
|
|
|
if(ch == "backspace"){ DOTGRID.tool.removeSegment(); e.preventDefault(); }
|
2018-10-04 19:52:17 -04:00
|
|
|
if(ch == "escape"){ DOTGRID.tool.clear(); DOTGRID.picker.stop(); e.preventDefault(); }
|
|
|
|
|
2019-01-08 22:49:34 -05:00
|
|
|
if(ch == "1"){ DOTGRID.tool.selectLayer(0); e.preventDefault(); }
|
|
|
|
if(ch == "2"){ DOTGRID.tool.selectLayer(1); e.preventDefault(); }
|
|
|
|
if(ch == "3"){ DOTGRID.tool.selectLayer(2); e.preventDefault(); }
|
2018-10-04 19:52:17 -04:00
|
|
|
|
2019-01-08 22:12:18 -05:00
|
|
|
if(ch == "h"){ DOTGRID.renderer.toggle(); e.preventDefault(); }
|
2018-10-04 19:52:17 -04:00
|
|
|
if(ch == "?"){ DOTGRID.reset(); DOTGRID.theme.reset(); e.preventDefault(); }
|
|
|
|
|
|
|
|
if(ch == "a"){ DOTGRID.tool.cast("line"); e.preventDefault(); }
|
|
|
|
if(ch == "s"){ DOTGRID.tool.cast("arc_c"); e.preventDefault(); }
|
|
|
|
if(ch == "d"){ DOTGRID.tool.cast("arc_r"); e.preventDefault(); }
|
2018-11-15 18:17:17 -05:00
|
|
|
if(ch == "t"){ DOTGRID.tool.cast("arc_c_full"); e.preventDefault(); }
|
|
|
|
if(ch == "y"){ DOTGRID.tool.cast("arc_r_full"); e.preventDefault(); }
|
2018-10-04 19:52:17 -04:00
|
|
|
if(ch == "f"){ DOTGRID.tool.cast("bezier"); e.preventDefault(); }
|
|
|
|
if(ch == "z"){ DOTGRID.tool.cast("close"); e.preventDefault(); }
|
|
|
|
|
|
|
|
if(ch == "q"){ DOTGRID.tool.toggle("linecap"); e.preventDefault(); }
|
|
|
|
if(ch == "w"){ DOTGRID.tool.toggle("linejoin"); e.preventDefault(); }
|
|
|
|
if(ch == "e"){ DOTGRID.tool.toggle("mirror"); e.preventDefault(); }
|
|
|
|
if(ch == "r"){ DOTGRID.tool.toggle("fill"); e.preventDefault(); }
|
|
|
|
if(ch == "g"){ DOTGRID.picker.start(); e.preventDefault(); }
|
|
|
|
if(ch == "}"){ DOTGRID.tool.toggle("thickness",1); e.preventDefault(); }
|
|
|
|
if(ch == "{"){ DOTGRID.tool.toggle("thickness",-1); e.preventDefault(); }
|
|
|
|
if(ch == "]"){ DOTGRID.tool.toggle("thickness",5); e.preventDefault(); }
|
|
|
|
if(ch == "["){ DOTGRID.tool.toggle("thickness",-5); e.preventDefault(); }
|
2018-09-11 21:20:31 -04:00
|
|
|
|
2019-01-07 17:34:57 -05:00
|
|
|
if(ch == "m"){ DOTGRID.tool.merge(); e.preventDefault(); }
|
|
|
|
|
2018-10-04 19:52:17 -04:00
|
|
|
if(ch == "i"){ DOTGRID.theme.invert(); e.preventDefault(); }
|
2018-10-01 15:38:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
document.onkeydown = (e) =>
|
|
|
|
{
|
2019-01-08 22:49:34 -05:00
|
|
|
if(e.keyCode == 9){ DOTGRID.tool.selectNextLayer(); e.preventDefault(); }
|
2018-08-17 17:34:24 -04:00
|
|
|
}
|