OnKeyPress in a arduino
This is an ordinary method (function) which can not be instantiated. It is necessary to write a class with 1 or more methods in it in order to instantiate multiple copies of that class and the method(s) with in that class.

The integers "LastState", "BeginState" and "r" only have scope within the method and will not survive after returning from the method.  There are several approaches to preserve these variables from one call to the next.  They can be declared as static integers.  Or they can be defined globally.

It appears you are recreating the existing Bounce library.  I encourage you to continue if you are learning.  However, you may want to look at the Bounce library's code for guidance.