2016-12-31 12:37:10 -05:00
|
|
|
function Keyboard()
|
|
|
|
{
|
|
|
|
this.listen = function(event)
|
|
|
|
{
|
2017-11-05 14:53:59 -05:00
|
|
|
// save
|
|
|
|
if(event.key == "s" && (event.ctrlKey || event.metaKey)){
|
|
|
|
dotgrid.export();
|
|
|
|
return;
|
|
|
|
}
|
2017-11-05 14:38:14 -05:00
|
|
|
|
2016-12-31 12:56:25 -05:00
|
|
|
switch (event.keyCode) {
|
2017-11-05 00:33:04 -04:00
|
|
|
case 83 : dotgrid.draw_arc(event.shiftKey ? "1,1" : "0,1"); break;
|
|
|
|
case 65 : dotgrid.draw_arc(event.shiftKey ? "1,0" : "0,0"); break;
|
2017-11-04 20:52:05 -04:00
|
|
|
case 68 : dotgrid.draw_line(); break;
|
2017-11-04 19:59:11 -04:00
|
|
|
case 70 : dotgrid.draw_bezier(); break;
|
2017-11-05 00:33:04 -04:00
|
|
|
case 82 : dotgrid.draw_close(); break;
|
2017-11-04 19:59:11 -04:00
|
|
|
case 187 : dotgrid.mod_thickness(1); break;
|
|
|
|
case 189 : dotgrid.mod_thickness(-1); break;
|
|
|
|
case 191 : dotgrid.mod_linecap(1); break;
|
2016-12-31 15:55:35 -05:00
|
|
|
|
|
|
|
case 81 : dotgrid.reset(); break;
|
2017-11-04 19:59:11 -04:00
|
|
|
case 27 : dotgrid.reset(); break;
|
2016-12-31 15:55:35 -05:00
|
|
|
case 87 : dotgrid.erase(); break;
|
2017-11-04 19:59:11 -04:00
|
|
|
case 8 : dotgrid.erase(); break;
|
2017-01-04 13:25:40 -05:00
|
|
|
case 69 : dotgrid.export(); break;
|
2017-01-04 12:48:08 -05:00
|
|
|
|
2017-11-04 19:59:11 -04:00
|
|
|
case 38 : dotgrid.mod_move(0,-1); break;
|
|
|
|
case 40 : dotgrid.mod_move(0,1); break;
|
|
|
|
case 37 : dotgrid.mod_move(1,0); break;
|
|
|
|
case 39 : dotgrid.mod_move(-1,0); break;
|
2016-12-31 12:37:10 -05:00
|
|
|
}
|
2017-11-04 19:59:11 -04:00
|
|
|
dotgrid.draw();
|
2016-12-31 12:37:10 -05:00
|
|
|
}
|
|
|
|
}
|