Prevent native browser undo/redo when handled by app

This commit is contained in:
orangemug 2019-05-18 15:47:51 +01:00
parent c3c0c35d8a
commit 979fc98e70

View file

@ -217,20 +217,24 @@ export default class App extends React.Component {
}) })
} }
handleKeyPress(e) { handleKeyPress = (e) => {
if(navigator.platform.toUpperCase().indexOf('MAC') >= 0) { if(navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
if(e.metaKey && e.shiftKey && e.keyCode === 90) { if(e.metaKey && e.shiftKey && e.keyCode === 90) {
e.preventDefault();
this.onRedo(e); this.onRedo(e);
} }
else if(e.metaKey && e.keyCode === 90) { else if(e.metaKey && e.keyCode === 90) {
e.preventDefault();
this.onUndo(e); this.onUndo(e);
} }
} }
else { else {
if(e.ctrlKey && e.keyCode === 90) { if(e.ctrlKey && e.keyCode === 90) {
e.preventDefault();
this.onUndo(e); this.onUndo(e);
} }
else if(e.ctrlKey && e.keyCode === 89) { else if(e.ctrlKey && e.keyCode === 89) {
e.preventDefault();
this.onRedo(e); this.onRedo(e);
} }
} }