I don't understand why with Firefox when I launch keydown event with space my click event is also launched.
With enter no problem.
var eventFunction = function(e) {
if (content.style.display === 'none' || content.style.display === '') {
content.style.display = 'block';
} else {
content.style.display = 'none';
}
}
button.addEventListener('click', function(e){
console.log('click');
eventFunction(e);
this.removeEventListener('click', eventFunction, false);
}, false);
button.addEventListener('keydown', function(e) {
console.log('keydown');
if(e.keyCode === 13 || e.keyCode === 32) {
eventFunction(e);
e.stopPropagation();
e.preventDefault();
this.removeEventListener('keydown', eventFunction, false);
}
}, false);
Demo here : https://jsfiddle.net/korigan/f371vcxx/