Your fiddle does not work. The code:
event.preventDefault();
Should be:
e.preventDefault();Since the function constructor looks like:
window.onkeydown=function(e){ Plus, I'd need to double check that preventDefault() is a DOM command. I only use it through jQuery.
You should also consider using jQuery to perform the key function. The code looks like:
$(document.documentElement).keydown(function(event) {
event.preventDefault();
if(event.which === 32) {
if(
$("#jquery_jplayer_1").data("jPlayer").status.paused) {
$("#jquery_jplayer_1").jPlayer("play");
} else {
$("#jquery_jplayer_1").jPlayer("pause");
}
}
});