I need help with a little code entry pad.

its pin 2 - 10, so yeah the buttons are numbered 2-10 as long that is remembered in the coding it wont effect the way the hardware looks and works.
how do i restrict Y, by adding a different variable to 1 and then when Y = 2, set the different variable to 0?