Skip to content

Commit

Permalink
fixed keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
ritz078 committed Apr 23, 2016
1 parent 2a519db commit 9b05bb5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions dist/client/handleShortCuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ exports.default = handleShortCuts;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function isModifierPressed(e) {
return (e.ctrlKey || e.keyCode === 91 || e.metaKey) && e.shiftKey;
}

function handleShortCuts(e, syncedStore) {
if (e.keyCode === 79 && e.ctrlKey && e.shiftKey) {
if (isModifierPressed(e) && e.keyCode === 80) {
e.preventDefault();
var newData = (0, _extends3.default)({}, syncedStore.getData());
newData.showSearchBox = !newData.showSearchBox;
syncedStore.setData(newData);
} else if (e.ctrlKey && e.keyCode === 76 && e.shiftKey) {
} else if (isModifierPressed(e) && e.keyCode === 76) {
e.preventDefault();
var _newData = (0, _extends3.default)({}, syncedStore.getData());
_newData.showControls = !_newData.showControls;
syncedStore.setData(_newData);
} else if (e.keyCode === 27) {
var _newData2 = (0, _extends3.default)({}, syncedStore.data);
_newData2.showSearchBox = false;
syncedStore.setData(_newData2);
} else if (e.keyCode === 66 && e.ctrlKey && e.shiftKey) {
} else if (isModifierPressed(e) && e.keyCode === 66) {
e.preventDefault();
var _newData3 = (0, _extends3.default)({}, syncedStore.getData());
_newData3.showLogger = !_newData3.showLogger;
syncedStore.setData(_newData3);
Expand Down
13 changes: 10 additions & 3 deletions src/client/handleShortCuts.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
function isModifierPressed(e) {
return (e.ctrlKey || e.keyCode === 91 || e.metaKey) && e.shiftKey;
}

export default function handleShortCuts(e, syncedStore) {
if (e.keyCode === 79 && e.ctrlKey && e.shiftKey) {
if (isModifierPressed(e) && e.keyCode === 80) {
e.preventDefault();
const newData = { ...syncedStore.getData() };
newData.showSearchBox = !newData.showSearchBox;
syncedStore.setData(newData);
} else if (e.ctrlKey && e.keyCode === 76 && e.shiftKey) {
} else if (isModifierPressed(e) && e.keyCode === 76) {
e.preventDefault();
const newData = { ...syncedStore.getData() };
newData.showControls = !newData.showControls;
syncedStore.setData(newData);
} else if (e.keyCode === 27) {
const newData = { ...syncedStore.data };
newData.showSearchBox = false;
syncedStore.setData(newData);
} else if (e.keyCode === 66 && e.ctrlKey && e.shiftKey) {
} else if (isModifierPressed(e) && e.keyCode === 66) {
e.preventDefault();
const newData = { ...syncedStore.getData() };
newData.showLogger = !newData.showLogger;
syncedStore.setData(newData);
Expand Down

0 comments on commit 9b05bb5

Please sign in to comment.