How does it check the states, does it scans all the keys from 0 to 255? If so, just make an array that matches every key number to the corresponding ascii code and get the ascii value from it.