It no longer waits for a key tap if it doesn't need to do that. Also, normalized the source code formatting.