1

I need to target virtual keys and determine when they were pressed with jQuery. Specifically the mute button.

I found these references, and notice that I need to target virtual keys, but have found no references on how to do so.

Mac: https://stackoverflow.com/a/16125341

Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

If jQuery isn't capable of this, are there any other suggestions?

Thanks.

ac.

Community
  • 1
  • 1
ancoanco
  • 220
  • 6
  • 17

2 Answers2

0

Virtual keys / on-screen keyboards ought to be the same -

You can test this by examining the console output of:

$("body").on("keydown",function(e) { 
    console.log(e.which); 
    }); 

The number displayed in your console should be the same for both the hard keyboard and the soft keyboard.

rm-vanda
  • 3,122
  • 3
  • 23
  • 34
  • This doesn't work for virtual keys. You can test by copying your code into the console of this page and seeing the output. – ancoanco Jan 26 '15 at 03:19
-1

Try this

$(document).keydown(function (event) {
    console.log('keydown', event);
});

and check if something is being output in the browser console when the desired key is pressed. If so, check which events properties you can use to distinguish this key press from others, consider the following properties

event.keyCode
event.metaKey
event.shiftKey
event.altKey
event.ctrlKey

In case nothing is being output, you are in trouble - browser is not capable of capturing this event.

Anton Boritskiy
  • 1,539
  • 3
  • 21
  • 37