How to detect key press event for enter key in GTKMM

I am using “on_key_press(GdkEvent *key)” method to get the values of key
pressed, what i found was that for keys like “Enter” and “Space Bar” no event key_press is generated.

If i am using enter with shift and crtl is detecting but for alone enter no key press generates.

It’s possible that your signal handler must be called before the default signal handler.
Set the after parameter in connect() to false. For instance

widget.signal_key_press_event(sigc::mem_fun(*this, &ExampleWindow::on_key_press), false);

There is a section about X Event signals in the gtkmm tutorial.
The gtkmm3 version is usually available at,
but right now I get Error 503 first byte timeout when I try to access it.

I assume that you use gtkmm3. In gtkmm4 you should use Gtk::EventControllerKey.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.