title: Pass function to a jquery key event?
body: <p>I have a function <code>foo(peram)</code> which I want to call from multiple jquery <code>.keyup()</code> events.</p>
  
  <p>How can I define/pass function <code>foo</code> so that I can call it from inside the event?</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>function foo(peram) {
  alert(peram);
  }
  
  $("#someElement").keyup(function(alert) {
  foo("You pressed a key!");
  });
  </code></pre>
  
  <p>However I get <code>TypeError: foo is not a function</code>.</p>
  
  <hr>
  
  <h1><strong>Update:</strong></h1>
  
  <p>I have removed everything from my script and html, and it still does not work.</p>
  
  <p><strong>html:</strong></p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script src="../jquery-1.10.2.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="test.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload="asdf()"&gt;
        &lt;input type="text" name="name"&gt;
    &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p><strong>test.js</strong>:</p>
  
  <pre><code>function asdf() {
  
  function hqxftg(stuff) {
    alert(stuff);
  }
  
  $(document).ready(function() {
  $('[name="name"]').keyup(function(hqxftg) {
    alert(typeof hqxftg) 
      hqxftg("asdf");
  })
  })
  }
  </code></pre>
  
  <p>It does seem to work in jsfiddle for some reason.</p>