title: How to call "class method" from outside class in JavaScript?
body: <p>I've got some code in JavaScript and I'm looking to trigger a <code>ViewModel</code> method using a keyboard shortcut. What is the correct syntax? Here's my code:</p>
  
  <pre><code>document.addEventListener('keydown', function(event) {
      if (event.keyCode==27){
          ViewModel.escapePressed();
      }
  }, true);
  
  function ViewModel() {
      this.escapePressed=function(){
          // Code
      };
  }
  </code></pre>