Page MenuHome

Event system & keymap support for key detecting/ignoring key repeat events
Needs ReviewPublic

Authored by Campbell Barton (campbellbarton) on Jun 30 2019, 8:14 AM.



This patch adds is_repeat member to an event and an option for key-map items to handle repeat events.

The keymap author can choose if they want press events to activate when the key is held (this patch enables for text editing and frame changes, otherwise repeat events aren't acted on).

This resolves T40537: Holding down "R" causes rapid switching between rotate and trackball rotate.


  • Not proposing this for 2.80.
  • Currently only X11 is supported.
  • Uses ghost to track of the last held key which has auto-repeat enabled (using XKB when supported).
  • This isn't fool proof, once a non-blender window is active we can't tell the key state. Currently the held key is cleared when the window is activated.

Diff Detail

rB Blender
arcpatch-D5153_1 (branched from master)
Build Status
Buildable 5213
Build 5213: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from Event system & keymap support for key repeat events to Event system & keymap support for key detecting/ignoring key repeat events.Jun 30 2019, 8:32 AM
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)
  • Add Event.is_repeat to RNA
  • Use ghost to detect key repeat events
  • Clear keys when a window is activated
  • Use xkb, remove use of set to stored held keys
  • Merge branch 'master' into arcpatch-D5153 (withouth this I got an ASan crash on startup)
  • Fix changing "Repeat" in keymap item through Preferences not working
  • Fix resetting key map item not resetting "Repeat" property
Julian Eisel (Severin) requested changes to this revision.Mon, Sep 30, 5:12 PM

First off, sorry for taking so long to check on this. I actually did check earlier and noticed the following issue with the prefs which I wanted to investigate, but then the file browser stuff got in the way...

  • Noticed that changing the repeat property through the prefs doesn't do anything. Fixed the keymap side of this, but there are some further issues making this fail (see following).
  • The XKB implementation seems to always allow key repeat events on arrow keys, space bar, etc. Not too sure what the rationale behind that is and if that's the behavior we want too.
    • As a result, for a good amount of keymap items, the repeat property doesn't have an effect. E.g. text cursor move items. I don't have a strong opinion on if that's fine, but should be checked on.
  • I guess the industry compatible keymap should be updated too?

Just to test my fixes, you can use the backspace text.delete item, that works despite the XKB issue.

Also, do you have plans to check on other distros?


Hmm, would be nice if this could actually respect the keymap item property, would have to look into how simple/complicated that is though.

This revision now requires changes to proceed.Mon, Sep 30, 5:12 PM
  • Fix bitfield array check.
  • Fix clearing repeat when non-repeat key released.

Tested quickly, works fine now :)

The only thing stopping me from accepting it is that it's unclear what the plans for other OSes are. I could look into the Win32 implementation myself, but it'll have to wait a few days then.

For other OS's we could do something we have in the X11 under the comment:

/* No XKB support (filter by modifier). */

If they don't have the repeat information available, although ideally we could access this information.