added esc keybind

This commit is contained in:
srgooglo 2022-03-14 22:06:25 +01:00
parent 61452bfb7d
commit 28c655882c

View File

@ -247,6 +247,25 @@ export default class SettingsMenu extends React.PureComponent {
activeKey: "app"
}
componentDidMount() {
if (typeof this.props.close === "function") {
// register escape key to close settings menu
window.addEventListener("keydown", this.handleKeyDown)
}
}
componentWillUnmount() {
if (typeof this.props.close === "function") {
window.removeEventListener("keydown", this.handleKeyDown)
}
}
handleKeyDown = (event) => {
if (event.key === "Escape") {
this.props.close()
}
}
handlePageTransition = (key) => {
this.setState({
transitionActive: true,