Key event

Next to [Key] and [Shift]+[Key] combinations, Celestia also allows to intercept [Control]+[Key] combinations. None of the [Alt]+[Key] combinations however and [Ctrl]+[Shift]+[Key] combinations are not supported either but are reported as [Ctrl]+[key] combinations, so pressing [Ctrl]+[Shift]+[A] has the same result as pressing [Ctrl]+[A].

In other object oriented type environments "key state" info like [Shift] would be part of the event data packet; somewhat like this:

eventData{
   char     = string: the character pressed,
   shift    = boolean: the shift key was or was not pressed,
   control  = boolean: the control key was or was not pressed,
   alt      = boolean: the alt key was or was not pressed
   }

Not in Celestia.celx however; both character ánd state information is combined in the "char" field. For the keyboard key [A] for example this would result in one of the following:

Key pressed         Value of keyevent.char
-----------         ----------------------
[A]                = "a"
[Shift]+[A]        = "A"
[Ctrl]+[A]         = "C-a"
[Ctrl]+[Shift]+[A] = "C-a"
[Alt]+[A]          = no event

Not all key's yield a key event; the ones that don't comprise keys like the function and cursor keys and the Escape key. Also not all key presses result in what you would expect. Pressing the [Enter] key for instance results in "C-m" and pressing [Ctrl]+[Entert] in "C-j". So before you start using certain key combinations, you'd better write a little test script to see what happens. Like the script "key events" below.

Downloads