Search code examples
javascriptevent-handlingkeypressonkeypress

Detecting ctrl+f6 from javascript


I am working on an application where I need to detect whether user has pressed ctrl+f6 for certain navigation path. How to capture ctrl+f6 key press event in javascript/jquery?


Solution

  • Hope this helps (source)

    $(window).keydown(function(event) {
      if(event.ctrlKey && event.keyCode == 117 ) { //f6 keycode
        console.log("Hey! Ctrl + F6 event captured!");
        event.preventDefault(); 
      }
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    Hit Ctrl + F6 to see console log on this event.