Improving keyboard bindings code

This commit is contained in:
Bojan Zivkovic 2018-03-16 23:00:33 -04:00
parent 984581e01a
commit 7dfc5029a3

View file

@ -75,17 +75,13 @@ export default class App extends React.Component {
}
componentDidMount() {
Mousetrap.bind(['ctrl+z'], this.onUndo.bind(this));
Mousetrap.bind(['command+z'], this.onUndo.bind(this));
Mousetrap.bind(['ctrl+y'], this.onRedo.bind(this));
Mousetrap.bind(['command+shift+z'], this.onRedo.bind(this));
Mousetrap.bind(['mod+z'], this.onUndo.bind(this));
Mousetrap.bind(['mod+y', 'mod+shift+z'], this.onRedo.bind(this));
}
componentWillUnmount() {
Mousetrap.unbind(['ctrl+z'], this.onUndo.bind(this));
Mousetrap.unbind(['command+z'], this.onUndo.bind(this));
Mousetrap.unbind(['ctrl+y'], this.onRedo.bind(this));
Mousetrap.unbind(['command+shift+z'], this.onRedo.bind(this));
Mousetrap.unbind(['mod+z'], this.onUndo.bind(this));
Mousetrap.unbind(['mod+y', 'mod+shift+z'], this.onRedo.bind(this));
}
onReset() {