title: Executing Different Parts of JavaScript Code by Pressing Key and Clicking
body: <p>I have code for 3 different task which I want to execute by clicking and pressing a key, so there will be 3 different combination of clicking and pressing. For example- </p>
  
  <pre><code>window.addEventListener("keydown", function(e){
  if(e.keyCode === 16) {console.log('Yap! Shift works...');}
  
  
  if(e.keyCode === 17) {console.log('Yap! Ctrl works...');
  document.addEventListener('click',function (event) {
  console.log(event.target.className); 
  }, false);
            }     
  
   },false);
  </code></pre>
  
  <p>Now, when I press click shift key, I get related output, when I click <code>Ctrl</code> key and then click, I get the class name of the object I click on.</p>
  
  <p>But the problem is, the output keeps coming as much I hold the key!! I want to execute the part of my code for once, and exactly when the key is pressed and a clicked is occurred.</p>
  
  <p>How can I do that? </p>
  
  <p>In general, how can I execute 3 part of  code for three different tasks by clicking and pressing efficiently? </p>