support undo/redo for azerty keyboards (#630)

* support undo/redo for azerty keyboards

* migrate to event.key

* remove unnecessary shiftKey check

Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
Faustino Kialungila 2020-02-01 17:37:22 +01:00 committed by GitHub
parent 46791e6da1
commit 7c9e6dd3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 10 deletions

View File

@ -9,5 +9,5 @@ export const actionSelectAll: Action = {
};
},
contextItemLabel: "labels.selectAll",
keyTest: event => event[KEYS.META] && event.code === "KeyA",
keyTest: event => event[KEYS.META] && event.key === "a",
};

View File

@ -14,7 +14,7 @@ export const actionCopyStyles: Action = {
return {};
},
contextItemLabel: "labels.copyStyles",
keyTest: event => event[KEYS.META] && event.shiftKey && event.code === "KeyC",
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "C",
contextMenuOrder: 0,
};
@ -46,6 +46,6 @@ export const actionPasteStyles: Action = {
};
},
contextItemLabel: "labels.pasteStyles",
keyTest: event => event[KEYS.META] && event.shiftKey && event.code === "KeyV",
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "V",
contextMenuOrder: 1,
};

View File

@ -18,8 +18,7 @@ export const actionSendBackward: Action = {
},
contextItemLabel: "labels.sendBackward",
keyPriority: 40,
keyTest: event =>
event[KEYS.META] && event.shiftKey && event.altKey && event.code === "KeyB",
keyTest: event => event[KEYS.META] && event.altKey && event.key === "B",
};
export const actionBringForward: Action = {
@ -32,8 +31,7 @@ export const actionBringForward: Action = {
},
contextItemLabel: "labels.bringForward",
keyPriority: 40,
keyTest: event =>
event[KEYS.META] && event.shiftKey && event.altKey && event.code === "KeyF",
keyTest: event => event[KEYS.META] && event.altKey && event.key === "F",
};
export const actionSendToBack: Action = {
@ -45,7 +43,7 @@ export const actionSendToBack: Action = {
};
},
contextItemLabel: "labels.sendToBack",
keyTest: event => event[KEYS.META] && event.shiftKey && event.code === "KeyB",
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "B",
};
export const actionBringToFront: Action = {
@ -57,5 +55,5 @@ export const actionBringToFront: Action = {
};
},
contextItemLabel: "labels.bringToFront",
keyTest: event => event[KEYS.META] && event.shiftKey && event.code === "KeyF",
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "F",
};

View File

@ -383,7 +383,8 @@ export class App extends React.Component<any, AppState> {
}
elements = clearSelection(elements);
this.setState({ elementType: shape });
} else if (event[KEYS.META] && event.code === "KeyZ") {
// Undo action
} else if (event[KEYS.META] && /z/i.test(event.key)) {
event.preventDefault();
if (