JSFiddle - React, Tailwind, and code Playground
HTML
<div class="cont">
Click Alt + Ctrl<br /><br />
<div id="res"></div>
</div>
CSS
.cont{
width: 110px;
margin: 0 auto;
}
#res{
border: 1px solid black;
border-radius: 3px;
background-color: #e5e5e5;
width: 100px;
height: 30px;
font-size: 20px;
margin: 0 auto;
text-align: center;
padding: 10px;
}
JavaScript
var lastAltLocation;
document.addEventListener("keydown", function(e) {
if (e.key == "Alt"){
lastAltLocation = e.location;
}
if (e.ctrlKey && e.altKey){
if (lastAltLocation == 1){
document.getElementById("res").innerHTML = "Left";
}
if (lastAltLocation == 2){
document.getElementById("res").innerHTML = "Right";
}
}
}, false);