Q:

C++ hook keyboard key pressed and key released

I'm trying to experiment with keyboard hooking.  Meaning I'm trying to capture key press and key release.  
I tried going over a loop with an array of keys, where key is the key value that is currently being checked : 
GetAsyncKeyState(key) & 0x8000

The following example, capturing the key press multiple times.  
The result I'm looking for is to capture the key only on the first press, if it releases it can be typed again.  

A:

So the trick was basically work with the function GetAsyncKeyState, and count each key how many times it was pressed. 
if the count equals to 1, so return key is pressed ( once ) 
this is my class : 
class Key {
private:
    unsigned char key;
    int count;
public:
    Key(unsigned char key) {
        this->key = key;
    }
    void captureKey() {
        if (GetAsyncKeyState(key) & 0x8000) {
            count++;
        }
        else {
            count = 0;
        }
    }
    bool isPressed() {
        return count == 1;
    }
    unsigned char getKey() {
        return this->key;
    }

};

