Using keypressed with arrow keys

Hi, my program is working when I do something like if(key== ‘a’), but I’m wondering how do I make it run when pressing the arrow keys instead of a letter key? What is the name that I put for the arrow keys? I tried if(key==‘UP’) but it did not work

Hi @closet8 , the arrow keys are OF_KEY_LEFT for left arrow, OF_KEY_RIGHT for right arrow, etc. You can even access the function keys, like F1 as OF_KEY_F1. I don’t know if there is a list of them or not; I usually rely on the ide (Qt Creator) to give me a short list of options.

Here’s a quick example:

void ofApp::keyPressed(int key){
    if(key == OF_KEY_UP) {ofLogNotice("up arrow pressed");}
}