Modifier keys overriding keyPressed events [OSX, 0.10.0]


Hello, in 0.10 w. High Sierra I’m not registering two keypresses when a modifier key is also pressed. For example;

void ofApp::keyPressed( ofKeyEventArgs& e) {
    ofLog() << "ofApp::" << (e.key == 'a') << (ofGetKeyPressed(OF_KEY_COMMAND));

Log output is;

ofApp:: 0 1 // cmd is pressed
ofApp:: 0 1 // + a is pressed

Same for permutations

ofLog() << "ofApp::" << (ofGetKeyPressed('a')) << (ofGetKeyPressed(OF_KEY_COMMAND));
// etc

Though it works for two non-modifier keys…


you should try ofxModifierKeys
I’m not sure if is still works on high sierra.


in 0.10 you can now check the modifiers in the event as:

void ofApp::keyPressed( ofKeyEventArgs& e) {


Hmm, still unable to get this to work - I’m in a blank project, OF 0.10.0 with High Sierra;

void ofApp::keyPressed(ofKeyEventArgs& e){

    if (e.key == 's') {
        ofLog() << "Left" << e.hasModifier(OF_KEY_LEFT_COMMAND);
        ofLog() << "Any" << e.hasModifier(OF_KEY_COMMAND);
        ofLog() << "Right" << e.hasModifier(OF_KEY_RIGHT_COMMAND);

Event fires if CMD isn’t held down, doesn’t fire if it is held down?


Is this recent commit related?


@autr yes this is a problem with 0.10 in macos. It’s solved already in github and should work with today nightly build and the next official release which should happen soon


Ah, thank you for the pointer :ok_hand: