One of the requirements of our customer is for the support of hot keys for different buttons(like save,create etc) in our application(using jsf 2.0) and the user should only do one key press. i.e. in case of Save button, if I click on say F1 key, the save button should be clicked.
Invoking the save button thru access key in JSF: Lets say, 's' is the access key for the Save button in my page. To click on the save button using access key, user needs to click on the alt,shift and then the 's' key. Alt and shift keys will differ based on the browser but the 's' key which is assigned will be constant.
Since I want the user to click on only one key(say F1), I would like to programatically trigger the Alt+Shift+ 's' key press.
Following is the code I have tried but didn't work.
$(document).keydown(function (e) {
if (e.which == 112) {
var e1 = $.Event("keydown", { keyCode: 83});
e1.altKey = true;
e1.shiftKey = true;
$("body").trigger(e1);
}
else {
console.log("you click on " + e.keyCode
+ " altkey= " + e.altKey + " shift key" + e.shiftKey);
}
});