adding a ring buffer to store key codes