How to prevent auto key repeat

Hi,
I need to find the way to prevent keypress() from auto repeat

use keyrelease() instead :slight_smile:

otherwise, you can compare current input with previous one

int pKey = 999999999999999;
void ofApp::keyPress(int key){
    if(key != pKey){
        do somthing..
    }
    pKey = key;
}

Thank you! it’s a awesome workaround. This is how I solved my problem.

int previousKey;
void ofApp::keyPressed(int key) {
    if (key != previousKey) {
        do sometihing...
    }
    previousKey = key;
}

void ofApp::keyReleased(int key) {
    previousKey = 999999999999999;
}

Because I don’t need to wait the key released to do something

1 Like

oh right! it’s needed to be reset for the next input with the same key. Good point ))

1 Like