Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I put together a fiddle with the functionality you specified <a href="http://jsfiddle.net/tppiotrowski/L7cm8/10/" rel="nofollow">http://jsfiddle.net/tppiotrowski/L7cm8/10/</a>. I hope I understood your requirements correctly. Let me know if you need any alterations or do not understand the code. Good luck!</p> <pre><code>var active = 0; //$('#navigate td').each(function(idx){$(this).html(idx);}); rePosition(); $(document).keydown(function(e) { reCalculate(e); rePosition(); // if key is an arrow key, don't type the user // input. if it is any other key (a, b, c, etc) // edit the text if (e.keyCode &gt; 36 &amp;&amp; e.keyCode &lt; 41) { return false; } }); $('td').click(function() { active = $(this).closest('table').find('td').index(this); rePosition(); }); function reCalculate(e) { var rows = $('#navigate tr').length; var columns = $('#navigate tr:eq(0) td').length; var temp; if (e.keyCode == 37) { //move left or wrap temp = active; while (temp &gt; 0) { temp = temp - 1; // only advance if there is an input field in the td if ($('#navigate tr td').eq(temp).find('input').length != 0) { active = temp; break; } } } if (e.keyCode == 38) { // move up temp = active; while (temp - columns &gt;= 0) { temp = temp - columns; // only advance if there is an input field in the td if ($('#navigate tr td').eq(temp).find('input').length != 0) { active = temp; break; } } } if (e.keyCode == 39) { // move right or wrap temp = active; while (temp &lt; (columns * rows) - 1) { temp = temp + 1; // only advance if there is an input field in the td if ($('#navigate tr td').eq(temp).find('input').length != 0) { active = temp; break; } } } if (e.keyCode == 40) { // move down temp = active; while (temp + columns &lt;= (rows * columns) - 1) { temp = temp + columns; // only advance if there is an input field in the td if ($('#navigate tr td').eq(temp).find('input').length != 0) { active = temp; break; } } } } function rePosition() { console.log(active); $('.active').removeClass('active'); $('#navigate tr td').eq(active).addClass('active'); var input = $('#navigate tr td').eq(active).find('input').focus(); scrollInView(); } function scrollInView() { var target = $('#navigate tr td:eq(' + active + ')'); if (target.length) { var top = target.offset().top; $('html,body').stop().animate({ scrollTop: top - 100 }, 400); return false; } }​ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload