This problem is totally unrelated to forms. Moreover, it is unrelated to C# and ASP.NET. The only relevance to ASP.NET is that you can write/generate JavaScript in ASP.NET code, but all works is done on the client side by JavaScript, no matter what you do. You should handle the event
keydown
and check the key and key states.
This is the useful resource:
http://www.asquare.net/javascript/tests/KeyCode.html[
^].
It could be something like this:
window.onkeydown = function(eventInstance) {
if (
eventInstance.ctrlKey
&& !eventInstance.shiftKey
&& !eventInstance.altKey
&& !eventInstance.metaKey
&& eventInstance.keyCode == 65)
alert("Ctrl-A");
}
Not that it works no regardless any controls you may have on the page, even if one holds the keyboard focus. Also note that I checked up that other status keys are not pressed; you can change it.
For testing, I used 'A' instead of 'Q', because 'Q' (81 instead of 65) is often used by browsers for other purposes. But if you want Ctrl+Q, please try using it, or whatever else you want.
—SA