Way to detect original keycode while Control key is pressed?

Hi, I have an OF app that uses hotkeys used in combination with the Control key.
The app works fine on Ubuntu. but on Windows if I press keys while the Control key is pressed, the keycode changes.
It’s not a problem for alphabet letters as I can just subtract ‘96’ from the original value. (e.g keycode for ‘a’ which is ‘97’ becomes ‘1’ when pressed with the Control key)
But for numeric letters,(also - =) all of them changes to ‘-1’ when pressed while the Control key is pressed.
Is there any possible solution to detect the original keycode of numeric values even while the Control key is pressed?

is this with 0.9.8 or master?

I used 0.9.8.

if you use the full event, using ofKeyEventArgs and adding a listener yourself instead of directly using ofApp::keyPressed, you can read the keycode which should be independent from modifiers: https://github.com/openframeworks/openFrameworks/blob/stable/libs/openFrameworks/events/ofEvents.h#L70

what you can’t read from the event in 0.9.8 that you can in 0.10 is which modifers are pressed at the same time as that key

1 Like

Thanks a lot! I’ll give it a try.

I just tried as you suggested. Here’s my test code.

In ofApp.h, add this inside ofApp class

void keycodePressed(ofKeyEventArgs& e);

And in ofApp.cpp,

void ofApp::setup(){
    ofAddListener(ofGetWindowPtr()->events().keyPressed, this,

void ofApp::update(){

void ofApp::draw(){

void ofApp::keycodePressed(ofKeyEventArgs& e){
    cout << "KEY : " << e.key << endl;
    cout << "KEYCODE : " << e.keycode << endl;

When I run the app and type keys, e.key and e.keycode returns different values. Shouldn’t keycode be identical to key but works independent from modifiers? Is this natrual? Thanks.

I tried this on MacOS, Ubuntu and Windows10 and they all have the same result.

As @arturo said, e.keycode returned consistent values regardless of modifier although the values are different from e.key value.
So I simply replaced my hotkey characters to corresponding e.keycode value in integer and now it works fine without the problem across different platforms. Thanks!