You don't have it to do this way. You can put most of the code direct in the keyboard events, but this is my way to do it, because I like it clearly arranged and I think it is easier to maintain.
There are several other ways to arrange the code, it's all about personal preferences.