Using (fake link click) stops other links from working?

I have a link(link1) in my top navbar that opens a sliding down menu with links to different page(on desktop) . It sets a flag and then checks if it is opened or not when you click the link.(this works as it should-opening and closing the menu)

var flagga=true;
$$(document).on("click",".openstoramenyn", function(){
	   $$(document).find('.storamenyn').animate({"top":"59px"}, { duration:300, easing: 'linear'});
	   flagga = false;
	   $$(document).find('.storamenyn').animate({"top":"-"+hojden+"px"}, { duration:300, easing: 'linear'});
	   flagga = true;

Then in that menu I have a link(link2 with id=tabkategorierna) that opens the popup menu.

Now, if I click on the link2 to open the popup it works every time to open the popup and link1 is always working.

But if I instead open the popup with the key event "s"(for search) then after the popup is closed, link1 is not working anymore - it won´t open the top menu!?

When I click on the key "s" on my keyboard I run a click event on the id=tabkategorierna to trigger it to fake a click on the link with id=tabkategorierna.

So this is the code for opening the popup with the key "s" and faking a click on the id=tabkategorierna link.

var mykeysearchFunc;
mykeysearchFunc = function(event) {
  //o=79 s=83 f=70
  if ((event.keyCode === 79) || (event.keyCode === 83) || (event.keyCode === 70)){
    // Trigger the button element with a click
  if ((event.keyCode === 67) || (event.keyCode === 27)){

document.addEventListener("keydown", mykeysearchFunc)

So why does it work if I actually click on the link to open the popup and not when it is opened by running document.getElementById("tabkategorierna").click();
What is the difference between actually clicking on the link and run the fake click on it?

Why does link1 stop working after I run document.getElementById("tabkategorierna").click(); ?

Any help really appreciated, thanks.
Anybody who understands why this is happening, because I don´t!