Is there a way to detect when I press the letter q in Javascript. I am currently working on a keyboard macro for League of Legends that will press another key upon the letter q being pressed. I currently have the code for another key being pressed in applescript but i am not sure if it will send the key ingame. I will address that issue myself. I just need the complete javascript code for detecting q since i don't know the syntax very well.
            Asked
            
        
        
            Active
            
        
            Viewed 395 times
        
    1 Answers
0
            
            
        Try this
<html>
<head>
<script type="text/javascript">
    function getKeystroke(e){
        var keystroke;
        if(window.event){ // IE                 
            keystroke = e.keyCode;
        }else if(e.which){ // Netscape/Firefox/Opera                    
            keystroke = e.which;
        }
        alert(String.fromCharCode(keystroke));
    }
</script>
<body>
<form>
    <input type="text" onkeypress="getKeystroke(event)" />
</form>
</body>
</html>
        Tatarin
        
- 1,238
 - 11
 - 28