Кажется, дошло.
Верно понял?
<script language="javascript" type="text/javascript">
document.onkeydown = function checkKeycode(event)
{
var foc = document.activeElement;
if ( !(/a\d\d/.test(foc.id)) ) return true;
function Id(id){ return document.getElementById(id); }
var inputs = Id('cellMat').getElementsByTagName('input'),
lastId = inputs[inputs.length-1].id,
m = lastId.replace(/a(\d)\d/,'$1')*1,
n = lastId.replace(/a\d(\d)/,'$1')*1,
i = foc.id.replace(/a(\d)\d/,'$1')*1,
j = foc.id.replace(/a\d(\d)/,'$1')*1;
if (!event) var event = window.event;
if (event.keyCode) var keycode = event.keyCode; // IE
else if (event.which) var keycode = event.which; // all browsers
if (keycode == 37 && j>1) return Id('a'+i+(j-1)).focus();
if (keycode == 38 && i>1) return Id('a'+(i-1)+j).focus();
if (keycode == 39 && j<n) return Id('a'+i+(j+1)).focus();
if (keycode == 40 && i<m) return Id('a'+(i+1)+j).focus();
}
</script>
<div id="cellMat">
<input id="a11"><input id="a12"><input id="a13"><input id="a14"><br>
<input id="a21"><input id="a22"><input id="a23"><input id="a24"><br>
<input id="a31"><input id="a32"><input id="a33"><input id="a34"><br>
<input id="a41"><input id="a42"><input id="a43"><input id="a44">
</div>