TwKeyPressed (function)

int TwKeyPressed(int key, int modifiers)


Call this function to inform AntTweakBar when a keyboard event occurs.

AntTweakBar interprets this event and acts consequently if it corresponds to a registered key shortcut. So TwKeyPressed has to be called each time your app receives a keyboard event that is not handled directly by your app.

For your convenience, the received key shortcut is displayed at the bottom of the Help bar.

If you are using SDL, GLUT, GLFW or Windows (DirectX), the library provides some helper functions to handle events. See the section how to integrate for more details.



The ASCII code of the pressed key, or one of the TwKeySpecial codes.


One or a OR-ed combination of the TwKeyModifier constants.

Return value

  • 1 if the key event has been handled by AntTweakBar,
  • 0 otherwise.

See also