In this recipe, you will learn how to define a class that, when instantiated, can keep track of the button press events of a specific button on the board. We will use this class in later recipes in this chapter, in order to create objects that will keep track of button presses on push buttons A and B.
You will learn how to put common chunks of code into functions and classes, which will improve the code reuse in your projects. It can also help with large projects, in order to break up a lot of the logic into smaller, independent chunks of functions and classes. The implementation of this button event class will be kept generic on purpose, so that it can easily be reused in different projects.