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-01-03 23:30:27 +01:00
|
|
|
path: "edit.active",
|
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-02-03 14:51:54 +01:00
|
|
|
if (state.get().bookmarks.show.link) {
|
2019-01-24 21:28:11 +01:00
|
|
|
menu.close();
|
|
|
|
link.add();
|
|
|
|
};
|
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-02-03 14:51:54 +01:00
|
|
|
if (state.get().bookmarks.show.link) {
|
|
|
|
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) {
|
|
|
|
theme.random();
|
|
|
|
theme.render();
|
|
|
|
data.save();
|
|
|
|
};
|
2019-01-03 23:30:27 +01:00
|
|
|
}, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
_bind();
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
init: init
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|