ok, finally figured it out. the number you enter into the text box is the key (obviously). add up the digits and subtract the sum from the closest higher multiple of 9. that will be the answer. for example, enter the digits 321. they add up to 6. the answer will be 3 since the closest higher multiple of 9 is 9. enter 345 and the answer is 6. the digits 345 add up to 12, which is 6 less than 18 (again the closest higher multiple of nine.
i can't explain it in number theory, but i don't plan to try, either. maybe some day when i'm really bored i'll figure it out.