2019-01-03 23:30:27 +01:00
|
|
|
var keyboard = (function() {
|
|
|
|
|
|
|
|
var _bind = function() {
|
|
|
|
window.addEventListener("keydown", function(event) {
|
|
|
|
// esc
|
|
|
|
if (event.keyCode == 27) {
|
2019-02-03 14:51:54 +01:00
|
|
|
if (state.get().menu) {
|
2019-01-03 23:30:27 +01:00
|
|
|
menu.close();
|
|
|
|
shade.destroy();
|
2019-02-03 14:51:54 +01:00
|
|
|
} else if (state.get().modal) {
|
2019-01-03 23:30:27 +01:00
|
|
|
modal.destroy();
|
|
|
|
shade.destroy();
|
2019-02-03 14:51:54 +01:00
|
|
|
} else if (state.get().bookmarks.edit) {
|
|
|
|
helper.setObject({
|
|
|
|
object: state.get(),
|
2019-02-25 15:51:59 +01:00
|
|
|
path: "bookmarks.edit",
|
2019-02-03 14:51:54 +01:00
|
|
|
newValue: false
|
2019-01-03 23:30:27 +01:00
|
|
|
});
|
|
|
|
control.update();
|
|
|
|
control.render();
|
|
|
|
};
|
|
|
|
data.save();
|
|
|
|
};
|
|
|
|
// ctrl+alt+a
|
|
|
|
if (event.ctrlKey && event.altKey && event.keyCode == 65) {
|
2019-04-01 17:11:39 +02:00
|
|
|
if (state.get().bookmarks.link.show) {
|
2019-01-24 21:28:11 +01:00
|
|
|
menu.close();
|
|
|
|
link.add();
|
|
|
|
};
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
2019-04-01 17:11:39 +02:00
|
|
|
// ctrl+alt+d
|
|
|
|
if (event.ctrlKey && event.altKey && event.keyCode == 68) {
|
|
|
|
theme.toggle();
|
|
|
|
control.render();
|
|
|
|
control.update();
|
|
|
|
data.save();
|
|
|
|
};
|
2019-01-03 23:30:27 +01:00
|
|
|
// ctrl+alt+m
|
|
|
|
if (event.ctrlKey && event.altKey && event.keyCode == 77) {
|
|
|
|
shade.destroy();
|
|
|
|
modal.destroy();
|
|
|
|
menu.toggle();
|
|
|
|
};
|
|
|
|
// ctrl+alt+e
|
|
|
|
if (event.ctrlKey && event.altKey && event.keyCode == 69) {
|
2019-04-01 17:11:39 +02:00
|
|
|
if (state.get().bookmarks.link.show && bookmarks.get().length > 0) {
|
2019-02-03 14:51:54 +01:00
|
|
|
if (state.get().bookmarks.edit) {
|
|
|
|
helper.setObject({
|
|
|
|
object: state.get(),
|
|
|
|
path: "bookmarks.edit",
|
|
|
|
newValue: false
|
2019-01-24 21:28:11 +01:00
|
|
|
});
|
|
|
|
} else {
|
2019-02-03 14:51:54 +01:00
|
|
|
helper.setObject({
|
|
|
|
object: state.get(),
|
|
|
|
path: "bookmarks.edit",
|
|
|
|
newValue: true
|
2019-01-24 21:28:11 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
control.update();
|
|
|
|
control.render();
|
|
|
|
data.save();
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
};
|
2019-01-15 10:52:25 +01:00
|
|
|
// ctrl+alt+r
|
|
|
|
if (event.ctrlKey && event.altKey && event.keyCode == 82) {
|
2019-04-01 17:11:39 +02:00
|
|
|
accent.random();
|
|
|
|
accent.render();
|
2019-01-15 10:52:25 +01:00
|
|
|
data.save();
|
|
|
|
};
|
2019-01-03 23:30:27 +01:00
|
|
|
}, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
_bind();
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
init: init
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|