# Weird behavior of Keyboard events under Gtk4 on Linux

**URL:** https://discourse.julialang.org/t/weird-behavior-of-keyboard-events-under-gtk4-on-linux/129219
**Category:** Visualization
**Tags:** gtk4
**Created:** [May 21, 2025, 1:38pm UTC](https://discourse.julialang.org/t/weird-behavior-of-keyboard-events-under-gtk4-on-linux/129219 "2025-05-21T13:38:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mwlidar](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mwlidar](https://discourse.julialang.org/u/mwlidar)
#### Post date: [May 21, 2025, 1:38pm UTC](https://discourse.julialang.org/t/weird-behavior-of-keyboard-events-under-gtk4-on-linux/129219/1 "2025-05-21T13:38:51Z")

</div>

After testing my application on a Linux system I get some strange behavior of keyboard events.  
Here is a MWE to illustrate it:

```julia
    win = GtkWindow("Key Test", 300, 300)
    eck = GtkEventControllerKey(win)
    signal_connect(eck, "modifiers") do controller, state
        println("modifier = ", state)
    end
    signal_connect(eck, "key-pressed") do controller, keyval, keycode, state
        println("key pressed: ", keyval, " modifier: ", state)
    end
    show(win)

```

If I press first the shift key, then release it and then press the Ctrl key I get the following output on a Windows system, which is also what I would expect:

modifier = 1  
key pressed: 65505 modifier: 1  
modifier = 0  
modifier = 4  
key pressed: 65507 modifier: 4  
modifier = 0

On a Xubuntu 2.22 (x86-64) system the output is:

modifier = 0  
key pressed: 65505 modifier: 0  
modifier = 1  
modifier = 0  
key pressed: 65507 modifier: 0  
modifier = 4

So it seems the modifier values lag one event behind, which gives surprising results on application level…  
This is with Gtk4 0.7.7 and tested under Julia 1.10.9 and 1.11.5 all giving the same results.

Can anybody reproduce this? Hopefully there is an easy fix, because after a lot of coding to migrate from Gtk3 to Gtk4 I would not want to go back for Linux systems and maintain two version…

---

<div class="post-metadata">

### Author: ![mwlidar](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mwlidar](https://discourse.julialang.org/u/mwlidar)
#### Post date: [May 22, 2025, 7:37am UTC](https://discourse.julialang.org/t/weird-behavior-of-keyboard-events-under-gtk4-on-linux/129219/2 "2025-05-22T07:37:08Z")

</div>

Just tested it on an openSUSE 15.3 machine with the same result. So it is unlikely that come from an miss configured linux installation. Also tried without REPL, again with the same result…
