Changed key generation to asyncthread, and use event trigger KeyReady to get generated key