event->state
is a bitmap, which means that a value of 20 doesn't mean "20 instead of 4", but "4 and 16 at the same time". According to the headers, the value 16 (1 << 4
) corresponds to the MOD2
modifier, which might correspond to the fn key present on laptops.
A simple fix is to use the &
operator to check for control while ignoring other modifiers:
if (event->state & GDK_CONTROL_MASK && event->keyval == 'd')
which will work on both systems.