(function() {

  var toggle = document.querySelector("#hamburger");
  // var close = document.querySelector("#nav .close");
  toggleHandler(toggle);
  // toggleHandler(close);

  document.addEventListener('keydown', (event) => {
    var name = event.key;
    if (name.toLowerCase() === 'm'
      && event.target.nodeName.toLowerCase() !== 'input'
      && event.target.nodeName.toLowerCase() !== 'textarea') {
      toggle.click();
    }
  }, false);

  function toggleHandler(toggle) {

    toggle.addEventListener( "click", function(e) {
      e.preventDefault();

      ($('body').hasClass("-mobile-menu-active") === true) ? $('body').removeClass("-mobile-menu-active") : $('body').addClass("-mobile-menu-active");

      if ( $('body').hasClass("-mobile-menu-active") === true ) {
        toggle.setAttribute('aria-expanded','true');
        document.getElementById("buttonname").textContent="Navigation verbergen";
      } else {
        toggle.removeAttribute('aria-expanded');
        document.getElementById("buttonname").textContent="Navigation zeigen";
      }

    });
  }

})();
