jQuery: Input value lost on keyup?
<p>I have a simple form which I would like to submit (i.e fire ajax) when the user presses enter (return) on an input field. If I press the submit button the event fires fine, but when using keyup to fire the exact same function the value of the input field is blank. I tried passing the value of the input field (from the keyup function) using <strong>$(this).val()</strong>, but the passed param was still blank. </p>

<p><strong>Update II:</strong> The problem only occours on initial load. After hitting refresh the events fire as intended. Tested in Chrome and FF.</p>

<p><a href="http://jsfiddle.net/R5QsC/1/" rel="nofollow">http://jsfiddle.net/R5QsC/1/</a></p>

<pre><code>// Value of #pin is blank in getKeyAjax()
$('#pin').keyup(function(e) {
    if (e.keyCode == 13) {
        console.log('DEBUG: Keypress detected (13)')
        getKeyAjax();
    }
});
// Value of #pin is correct in getKeyAjax()
$('#btnPwdCreate').click(function() {
    getKeyAjax();
});

function getKeyAjax() {
    console.log('DEBUG: Starting ... getKeyAjax()');
    var txtPin = $('#pin').val();
    console.log('DEBUG: Value of txtPin: ' + txtPin);
   .
   .
   .
}
</code></pre>
