This thread almost solved my problem: Can jQuery .keypress() detect more than one key at the same time?
However, with the code provieded. If you press CTRL+C to copy some text, and then let go, the number will stay at "1" untill you pressed CTRL and R seperately.
The code:
var keys_count = 0;
var keys = {};
$(document).keydown(function (e) {
if(keys[e.which]) return;
keys_count = keys_count + 1;
keys[e.which] = true;
printKeys();
});
$(document).keyup(function (e) {
keys_count = keys_count - 1;
delete keys[e.which];
printKeys();
});
function printKeys() {
$('#out').html(keys_count);
}
Try my example here: http://jsfiddle.net/gFcuU/524/
Any ideas how to avoid this?
I simply want to track, wether the current user is simply typing some letters, or doing a command i.e. CTRL + C, CTRL + A, etc. But maybe there is an easier method, that I've found so far?