To make sure the event is coming from the keyboard, use keydown. To make sure this comes from the mouse, use mousekeydown. Therefore, you will need to register 2 different events for each device:
$(document).on('keydown', '.class', function (e) {
}
$(document).on('mousekeydown', '.class', function (e) {
}
source
share