Refactored some of the read key and generate key code to be more async w/ Promises.