Every browser is hogging the 'spacebar'
I have a couple divs that start hidden, and are supposed to pop up when an button is clicked. One div is a translucent backdrop over the whole page,the other has some content and appears atop the other overlay.
When divs are shown, I prompt the user to speak their name while holding the spacebar. But every time the user presses the space bar, the browser ALSO scrolls down the page.
mind you, keydown is working, but is performing two functions: recording (good and my idea) and scrolling down the page (bad, mozilla/google/apple idea).
so far i tried... document.keydown window.keydown $('#thediv').focus(); // this one was used to try and select the div through JS. When i manually clikc the element first it doesnt scroll down..
And before you ask the answer is: "yes"... it has to be the spacebar. Nothing else will do.
code:`
$('#triggeringlink').on('click',function(e){
//var text = $('#trans_source').val();
$("#page-cover").css("opacity",0.6).fadeIn(300, function () {
//dim the rest
$('#red').css({'position':'absolute','z-index':9999});
//and bring the board up to the top
$('#red').css('display','block');
var source = $('#trans_source').val();
$('#entercardsource').attr('value', source);
var target = $('#trans_target').val();
$('#entercardtarget').attr('value', target);
$('#red').focus();
//added for cards
//$("#focus_point").attr("tabindex",-1).focus();
var recording = false;
$(document).keydown(function(e){
if(e.keyCode == 32){
if(!recording){
//startRecording();
//recording = true;
alert('Recorrding');
}else{
//do nothing
}
}
}).keyup(function(e){
if(e.keyCode ==32){
//stopRecording();
//createDownloadLink();
recording = false;
alert('Stopped recording');
}
});
//alert(text);
});
e.preventDefault();
});
$('#page-cover').on('click', function(){
$('#page-cover').css('display','none');
$('#red').css('display','none');
//window eh for entering card audio
$(window).off('keydown');
$(window).off('keyup');`
that is a bit much to visualize. of course #red and #page-cover( the overlay) start offf as display:none. Any hints on this?