Mateo Torres
Mateo Torres

Reputation: 1625

How can I detect several keypresses in C GTK?

I'm writing a GTK based chat and want to implement the following:

In a GtkTextView when hitting Enter a message is sent, but hitting Shift+Enter types a new line.

I just can't figure out how to detect the multiple key press. I can detect just one key with GdkEventKey.

Upvotes: 1

Views: 342

Answers (1)

nos
nos

Reputation: 229058

Peek inside the state member of e GdkEventKey , it holds a bitmask of which of modifier keys (shift/control/alt and others) that are also pressed.

In the general case of detecting several keys being pressed, you have to keep track of the pressed keys yourself, i.e. on a key pressed event, you remember that the key is pressed, and on a key released event you forget the key.

Upvotes: 5

Related Questions