0

I have integrated lc_switch* button to my website to allow fullscreen mode. *: https://github.com/LCweb-ita/LC-switch The button and the function works perfectly but if I press "Esc" key to exit fullscreen mode the LC_switch button don't change position to "off".

https://codepen.io/Artenis/pen/xxOopyP

I have tried that with no result:

$(document).on('keyup', function(event) {
          if(event.key === "Escape") {
            $('.lcs_label_on').css('left','-50px');
            $('.lcs_label_off').css('right','0px');
}

edit : I have tried all solutions on the below page I got this function from here: How to detect escape key press with pure JS or jQuery?, and I tried to change Escape to == 27.

imagIne
  • 49
  • 1
  • 6

1 Answers1

0

I solved the problem thanks to the solution from mirage using window.resize function and lot of conditional.

accessing-escape-key-when-mozilla-is-in-full-screen

$(window).resize(function(){
if (window.navigator.standalone || (document.fullScreenElement && document.fullScreenElement !=null) || (document.mozFullScreen || document.webkitIsFullScreen) || (!window.screenTop && !window.screenY)){
}else{
    $(".lcs_switch").removeClass("lcs_on").addClass("lcs_off");
}
});
imagIne
  • 49
  • 1
  • 6