Files
pointvec/web/events.js

52 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-08-28 16:34:17 +12:00
'use strict';
2018-08-18 09:34:24 +12:00
document.onkeyup = (e) =>
{
2018-10-02 07:38:14 +12:00
const ch = e.key.toLowerCase();
2018-08-18 09:34:24 +12:00
2018-09-12 15:27:01 +12:00
if(e.target && e.target.id == "picker_input"){ return; }
2018-08-18 09:45:05 +12:00
2018-10-11 08:20:44 +12: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; }
2019-01-10 10:44:19 +12:00
if((e.ctrlKey || e.metaKey) && ch == "k"){ DOTGRID.tool.toggleCrest(); e.preventDefault(); return; }
2018-10-11 08:20:44 +12:00
2018-10-05 11:52:17 +12:00
if(ch == "backspace" && e.ctrlKey){ DOTGRID.theme.reset(); e.preventDefault(); }
2019-01-09 15:49:34 +12:00
if(ch == "backspace"){ DOTGRID.tool.removeSegment(); e.preventDefault(); }
2018-10-05 11:52:17 +12:00
if(ch == "escape"){ DOTGRID.tool.clear(); DOTGRID.picker.stop(); e.preventDefault(); }
2019-01-09 15:49:34 +12: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-05 11:52:17 +12:00
2019-01-09 15:12:18 +12:00
if(ch == "h"){ DOTGRID.renderer.toggle(); e.preventDefault(); }
2018-10-05 11:52:17 +12: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-16 12:17:17 +13: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-05 11:52:17 +12: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 13:20:31 +12:00
2019-01-08 10:34:57 +12:00
if(ch == "m"){ DOTGRID.tool.merge(); e.preventDefault(); }
2018-10-05 11:52:17 +12:00
if(ch == "i"){ DOTGRID.theme.invert(); e.preventDefault(); }
2018-10-02 07:38:14 +12:00
}
document.onkeydown = (e) =>
{
2019-01-09 15:49:34 +12:00
if(e.keyCode == 9){ DOTGRID.tool.selectNextLayer(); e.preventDefault(); }
2018-08-18 09:34:24 +12:00
}