multiple approaches …
On key press (down) set a boolean (keydown?) to true. On release set to false.
On mouse over/hover of the boxes check if keydown? is false … if so move, otherwise don’t.
another approach is to use “Is Input Key Down” as a conditional check on hover.