You can use the location to determine which Alt is pressed. To support Alt + Ctrl, we will save the last location of Alt pressed.
Location = 1 // Left Location = 2 // Right
Then, as soon as the Alt and Ctrl keys are pressed, do your thing. In this example, we simply write Alt as a result of the div. You can also add the condition "e":
if (e.ctrlKey && e.altKey && e.key == "e"){
Example
HTML
<div class="cont"> Click Alt + Ctrl<br /><br /> <div id="res"></div> </div>
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);
source share