First, you must enable the option goEditing in Options Stringgrid; Then, in the onKeyDown event, add the code (With ENTER):
if key = 13 then
begin
if StringGrid.Col < (StringGrid.ColCount - 1) then StringGrid.Col := StringGrid.Col + 1
else
if StringGrid.Row < (StringGrid.RowCount -1) then
begin
StringGrid.Col:= StringGrid.FixedCols;
if StringGrid.Row < (StringGrid.RowCount -1) then StringGrid.Row := StringGrid.Row + 1
end
else Perform(WM_NEXTDLGCTL,0,0);
end;
To do with the direction keys, use your ASC II codes:
37 (arrow to the left)
38 (arrow up)
39 (arrow to the right)
40 (arrow down)
Of course to use with the direction keys, an improved logic will have to be applied, above is just the path of the stones.