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
};
window.addEventListener("keydown", ev => {
if (ev.key === "Alt") {
const handleActionKeyEvents = (ev: KeyboardEvent) => {
if (ev.key === "Alt" || ev.key === "Shift") {
this.setState({
showAlternateAction: true
});
}
});
window.addEventListener("keyup", ev => {
if (ev.key === "Alt") {
this.setState({
showAlternateAction: false
// Only enable on keydown, otherwise disable
showAlternateAction: ev.type === "keydown"
});
}
}
window.addEventListener("keydown", handleActionKeyEvents);
window.addEventListener("keyup", handleActionKeyEvents);
window.addEventListener("blur", () => {
this.setState({
showAlternateAction: false
});
});
this.handleCast = this.handleCast.bind(this);
}