Skip to content

Commit

Permalink
Make redo keyboard shortcut work for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Mar 16, 2019
1 parent a4f550c commit c9c5902
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,17 @@ class App extends Component {

let sign = evt.key === 'ArrowUp' ? -1 : 1
this.startAutoscrolling(sign)
} else if ((evt.ctrlKey || evt.metaKey) && ['z', 'Z', 'y'].includes(evt.key)) {
} else if ((evt.ctrlKey || evt.metaKey) && ['z', 'y'].includes(evt.key.toLowerCase())) {
if (this.state.busy > 0) return

// Hijack browser undo/redo

evt.preventDefault()

let action = evt.key === 'z' ? 'undo'
: ['Z', 'y'].includes(evt.key) ? 'redo'
: null
let step = evt.key.toLowerCase() === 'z' ? -1 : 1
if (evt.shiftKey) step = -step

let action = step < 0 ? 'undo' : 'redo'

if (action != null) {
if (helper.isTextLikeElement(document.activeElement)) {
Expand Down

0 comments on commit c9c5902

Please sign in to comment.