console
$('input').on('keydown', function(e) {
console.log(e.key);
switch (e.keyCode) {
case 37:
$(this).closest('td').prevAll().find('input').last().select();
break;
case 39:
$(this).closest('td').nextAll().find('input').first().focuselect();
break;
default:
return;
}
})
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" />
</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>
<input type="text" />
</td>
<td>
<input type="text" />
</td>
</tr>
</tbody>
</table>