Fixed bug where key codes would get stuck in the array