So I have a basic understanding of writing code, the only way to get better from here is practice.
Welcome to "learning to program applications/games", an art that takes a life time to master.
The good news is that any solution that works is good. The bad news is that there are a lots of shades in "good". Some less good forms cause a lot of work for you, or fail with the smallest mistake. Other forms cause a lot of work for the computer, up to the point that it may need a few eons to give you an answer. (For much simpler problems than finding the question about life, the universe and everything, given that the answer is 42.)
On the positive side, if you pick the better good solutions, you can avoid some or most(?) of these problems. As you say, the only way to know which are the better solutions is by practice.
So with questions like you have above, my advice is to try it.
If not sure you need a class for something, try both forms. Make an as small as possible example (eg a game where you have to press 1 key), and code the form with class and without class. Leave it for a few days, then look at the code again asif someone else wrote it. What do you like about the solutions, is there a solution you like better? Try to extend it with another key, or five keys. Do a thought experiment, what if you have to add 100 keys? Do you have to copy a piece of code 100 times, or change just one number from 2 to 100, or something in-between? Is that acceptable? If not, how to improve?
Such small-scale experiments are quick to code, so you can make several alternatives and compare them. The goal here is to get understanding, the code is generally all thrown away afterwards.
I still do these things when I have to figure out how all the little details work, and what information you need where.
If you're getting confused, it's a sign you take a too big bite. See if you can split the problem in two or more smaller problems.
A second thing you can do is to read code made by others. Some code you will understand, some code just looks like black magic, and some looks intriguing as a novel solution to that one problem you had a month ago.
A third thing you can do is to join a group of other programmers, and exchange questions and answers/solutions. There are a lot of open source projects, and they are generally all looking for more developers to help them. The biggest problem of such projects is perhaps the sheer size of the code base, which is generally large. On the other hand, every project also problems that are very local, so you can ignore most of the code at first.