Skip to content

Instantly share code, notes, and snippets.

@oviava
Created November 4, 2015 10:20
Show Gist options
  • Save oviava/8c44c7f79260ce89ab9f to your computer and use it in GitHub Desktop.
Save oviava/8c44c7f79260ce89ab9f to your computer and use it in GitHub Desktop.
works on chrome, not on firefox ( event is not defined )
handleKeyDown(e) {
if (!e.ctrlKey) {
return;
}
e.preventDefault();
const key = event.keyCode || event.which;
const char = String.fromCharCode(key);
switch (char.toUpperCase()) {
case this.props.toggleVisibilityKey.toUpperCase():
this.props.dispatch(toggleVisibility());
break;
case this.props.changePositionKey.toUpperCase():
this.props.dispatch(changePosition());
break;
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment