Welcome to part 9 of the Python Plays: Grand Theft Auto series, where our first goal is to create a self-driving car. In this tutorial, we're going to cover how we can build a training dataset for a deep learning neural network.

If you're not fully up to speed with machine learning, I have a machine learning tutorial series, where you can also just mainly focus on the deep learning with Neural Networks and TensorFlow parts.

For training data, we need both features and labels. The featuresets will be the pixel data from the screen data. The labels are the key inputs we want the AI to make. We already have the pixel data, but we do not have a way of collecting inputs. We made inputs, but we need a way to capture our own inputs.

I researched for a way to log Python keys without the Python window being in focus, but came up empty-handed for anything that worked. I then took to Twitter to ask if anyone knew of a way, and Jake B (Their Github) offered a solution. I tweaked it slightly to suit my needs, and the result is the following, saved as getkeys.py: