Allow Shift key to show alternate receiver actions for Windows/Linux

This commit is contained in:
hensm
2020-02-13 01:29:09 +00:00
parent 174d566ded
commit dbd0a8c31f

View File

@@ -270,21 +270,25 @@ class ReceiverEntry extends Component<ReceiverEntryProps, ReceiverEntryState> {
, showAlternateAction: false , showAlternateAction: false
}; };
window.addEventListener("keydown", ev => { const handleActionKeyEvents = (ev: KeyboardEvent) => {
if (ev.key === "Alt") { if (ev.key === "Alt" || ev.key === "Shift") {
this.setState({ this.setState({
showAlternateAction: true // Only enable on keydown, otherwise disable
}); showAlternateAction: ev.type === "keydown"
}
});
window.addEventListener("keyup", ev => {
if (ev.key === "Alt") {
this.setState({
showAlternateAction: false
}); });
} }
}
window.addEventListener("keydown", handleActionKeyEvents);
window.addEventListener("keyup", handleActionKeyEvents);
window.addEventListener("blur", () => {
this.setState({
showAlternateAction: false
});
}); });
this.handleCast = this.handleCast.bind(this); this.handleCast = this.handleCast.bind(this);
} }