To add a new item to my database there is the Add button, however I would like to add a shortcut to it that performs the same function as the button. For example, when E is clicked on any question in the OS, it goes into edit mode.
In my case I thought of something like Shift + N to insert a new item.
By using keydown
you can detect that only one key was pressed, as shown in the example below:
$(document).keydown(function (e) {
if (e.keyCode == 16) {
alert("O código "+ e.which + " que representa o Shift foi precionado");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
To create the shortcut I thought something like:
if (e.keyCode == 16 && e.keyCode == 78)
In this case, the 78
corresponds to n , but it did not work this way.
How could I create a shortcut on my web page that would recognize the command shift + n ?