Navigating in a shapes array

I need some help on getting an algorithm to move from one shape to another in an array.
The user, using the arrow keys of the keyboard, would navigate from one shape to another.

See it mainly as an array of squares (which is the base element)
…but some elements are not squares but more “complex” shapes.

So, in a case where there is only “basic” shapes (column “F”)
the user jumps from one simple shape to one simple shape
But how would you do when he comes from columns “H”?:
Pressing down will jump from “1” to “2”,
then pressing down again will make it jump from “2” to “3”,
then finaly from “3” to “4”

How would you please script this using arrays?
Thanks a lot,