Modifier keys overriding keyPressed events [OSX, 0.10.0]


#1

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…


#2

you should try ofxModifierKeys https://github.com/satoruhiga/ofxModifierKeys
I’m not sure if is still works on high sierra.


#3

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

void ofApp::keyPressed( ofKeyEventArgs& e) {
    e.hasModifier(OF_KEY_COMMAND)
}

#4

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?


#5

Is this recent commit related?


#6

@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


#7

Ah, thank you for the pointer :ok_hand: