Execute jquery function upon enter key
<p>Okay .. this is my attempt to execute a function instead of calling from it from the  tag .. thing is .. it's not working .. mind you I'm still fresh with all these <em>sigh</em></p>

<pre><code>        &lt;div class="widget first"&gt;
                &lt;div class="head"&gt;&lt;h5 class="iFrames"&gt;Static table&lt;/h5&gt;&lt;/div&gt;
            &lt;table id="example" cellpadding="0" cellspacing="0" width="100%" class="tableStatic"&gt;
                &lt;thead&gt;
                        &lt;tr&gt;
                        &lt;td width="20%"&gt;Column 1&lt;/td&gt;
                        &lt;td width="20%"&gt;Column 2&lt;/td&gt;
                        &lt;td width="20%"&gt;Column 3&lt;/td&gt;
                        &lt;td width="20%"&gt;Column 4&lt;/td&gt;
                        &lt;td width="20%"&gt;Column 5&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;
                &lt;/tbody&gt;
            &lt;/table&gt;
        &lt;/div&gt;

&lt;input type="text" name="name" id="name" /&gt;
</code></pre>

<p>and the script would go:</p>

<pre><code>/* Global var for counter */
var giCount = 1;

$(document).ready(function() {
   $('#example').dataTable();
} );

function fnClickAddRow() {
    $('#example').dataTable().fnAddData( [
        $("#name").val(),
        giCount+".2",
        giCount+".3",
        giCount+".4",
        giCount+".5" ] );
     $("#name").val('').focus();
    giCount++;
}

$('#name').on('keyup', function(e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if (code == 13) {
       fnClickAddRow();
    }
});
</code></pre>

<p>Now, I'm trying to add new row with the value of "name" from the input upon entering. And it's not working :\ .. by the way in this example I'm using DataTables ...</p>
