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?
Asked
Active
Viewed 487 times
-1
Misha Akopov
- 11,071
- 26
- 66
- 81
Sayantan Ghosh
- 836
- 2
- 9
- 27
-
1Possibly the answer lies in this question https://stackoverflow.com/questions/424407/handling-key-press-events-f1-f12-using-javascript-and-jquery-cross-browser – John Rodney Dec 05 '17 at 10:32
-
Right. Missed it somehow. Thanks :) – Sayantan Ghosh Dec 05 '17 at 10:44
1 Answers
2
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.
Krzysztof Janiszewski
- 3,630
- 3
- 16
- 35