Hello,
the current nglWindow keyboard callbacks have some limitations, and
Meeloo asked for more proper support for keyboard shortcuts and input
methods. We came up with the following proposal: now OnKeyUp/Down
callback will pass a struct :
struct nglKeyEvent {
nglTime mTime; ///< Time stamp of the key event
nglKeyCode mCode; ///< Code of the physical key
nglString mRawString; ///< Output string, with modifiers ignored
nglString mString; ///< Output string, with normal input method
handling
};
Notable differences :
- new timestamp !
- textual results from a key events are strings, because in some
circumstances, a single key event (maybe combined with the precedent
ones) can result in multiples caracters. Of course, a textual result is
not always available (eg: event on NK_SHIFT), this is already
documented. As an alternative, we could continue with nglChar, but in
this case NGL would synthetize fake key events to pass several
characters upon a simgle key stroke if necessary (that's what _should_
be implemented currently ! Sorry ...).
- there are two textual result: the mRawString gives you the key as if
modifiers (shift, control, alt, etc.) where not taken into account. This
way you can correctly interpret the Ctrl+A sequence, it would give you
two events (eg. w/french AZERTY keyboard) :
* mCode = NK_LCTRL, mRawString = '', mString = ''
* mCode = NK_Q, mRawString = 'a', mString ='^A' (the latter being
quite platform dependent)
We plan to completely deprecate the current OnKeyUp/OnKeyDown
callbacks.
BTW, it would be a good idea to add a mTime timestamp in nglMouseInfo
also.