There are probably many ways to do it. If i was to do it my approach would be to have 5 variables on the space called ID,left,right,up,down and these are numbers. If the 4 directional variables are 0 it means you cannot move in that direction but if they are populated with a number greater than 0 it means you can move to the space that has that ID.
On the movements events it would be left key pressed checks the left variable of the space you are on, right key pressed checks the right variable of the space you are on etc. So as an example if you are on that starting space which has a variable space.down=2 and the space below it in the picture has an ID of 2, it means on down pressed you can move to 2. If it was space.down=0 then you wouldn't be able to move. And if the starting space has an ID of 1, then the space below it which has an ID of 2 would have a variable space.up=1.