Simple and fast way to do that would be to add a global variable that will save current state.
on pressing X - add 1 to "state" variable
Then you will only need to set "states" for the selections
state = 0 - > Select element in group of objects by pressing up or down
state = 1 -> Select second element in group of objects by pressing up or down
state = 3 -> etc