pointvec/web/events.js

49 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-08-28 04:34:17 +00:00
'use strict';
2018-08-17 21:34:24 +00:00
document.onkeyup = (e) =>
{
2018-10-01 19:38:14 +00:00
const ch = e.key.toLowerCase();
2018-08-17 21:34:24 +00:00
2018-09-12 03:27:01 +00:00
if(e.target && e.target.id == "picker_input"){ return; }
2018-08-17 21:45:05 +00:00
2018-10-10 20:20:44 +00: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 23:52:17 +00:00
if(ch == "backspace" && e.ctrlKey){ DOTGRID.theme.reset(); e.preventDefault(); }
if(ch == "backspace"){ DOTGRID.tool.remove_segment(); e.preventDefault(); }
if(ch == "escape"){ DOTGRID.tool.clear(); DOTGRID.picker.stop(); e.preventDefault(); }
if(ch == "1"){ DOTGRID.tool.select_layer(0); e.preventDefault(); }
if(ch == "2"){ DOTGRID.tool.select_layer(1); e.preventDefault(); }
if(ch == "3"){ DOTGRID.tool.select_layer(2); e.preventDefault(); }
if(ch == "h"){ DOTGRID.guide.toggle(); e.preventDefault(); }
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 23:17:17 +00: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 23:52:17 +00: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-12 01:20:31 +00:00
2018-10-04 23:52:17 +00:00
if(ch == "i"){ DOTGRID.theme.invert(); e.preventDefault(); }
2018-10-01 19:38:14 +00:00
}
document.onkeydown = (e) =>
{
2018-10-04 23:52:17 +00:00
if(e.keyCode == 9){ DOTGRID.tool.select_next_layer(); e.preventDefault(); }
2018-08-17 21:34:24 +00:00
}