let me start with your first question. In fact specifying the filter condition AnyKey will not provide the key code Enter as you have expected. Instead the code Core::KeyCode.Ok is reported when you press the ENTER key. Why is it so?
Embedded Wizard technology was designed years ago originally for TV sets. As you might know there is no ENTER key on a typical TV set remote control. Instead there is an OK key. In order to allow the developer to test how the TV set application will behave when particular remote control key is pressed we had thus to convert the PC keyboard keys in corresponding remote control keys. In particular pressing the key ENTER on the PC keyboard is reported as Core::KeyCode.Ok. See the Prototyper window chapter for a screenshot demonstrating this mapping.
Later we enhanced the keyboard functionality also to support application running on PC or other devices not TV sets. With this step we support many typical PC keyboard codes like ENTER, CTRL+C, etc. However, this approach is not compatible with the application running for 'old' TV sets. When the user presses the ENTER key, what should happen? Should the event be delivered as Core::KeyCode.Enter or Core::KeyCode.Ok code?
Our approach was to remain as far as good compatible with the codes used by older applications and allow new applications to work with new codes. This is achieved by sending the keyboard events twice. In particular: when the user presses the key ENTER we send first the code Core::KeyCode.Ok and try to find a handler for this code. If there is no handler found, we send another event Core::KeyCode.Enter. In this manner older TV set and newer PC like application can be developed and tested with Embedded Wizard.
Well, specifying the filter condition Core::KeyCode.AnyCode causes your key handler to respond to the first event with the code Core::KeyCode.Ok. Consequently, the code Core::KeyCode.Enter is not delivered anymore. This special compatibility mode is implemented primarily in the Prototyping window so the developer is able to test GUI applications in all cases (for old TV set or even other device). This Prototyper behavior can't be changed.
In turn, in the target device (in your final product) you have the full control of how the keyboard codes are mapped to the corresponding Core::KeyCode values. This, however, will not help you a lot since you want your application to run also in Prototyper. Therefore the best would be one of the following approaches:
Approach 1: Don't use Core::KeyCode.AnyCode.
Instead use several Key Press Handler objects, every configured with an individual code as filter condition. For example, you can add a handler and configure it with the filter condition Core::KeyCode.Enter. As described above the Prototyper will provide the appliction with the code Core::KeyCode.Enter if there is no other handler interesting in the Core::KeyCode.Ok.
Approach 2: Adapt the if-condition in your slot method.
if ( KeyHandler.Code == Core::KeyCode.Enter )
use following condition, which is true for both the 'old' Ok and the new Enter code:
if (( KeyHandler.Code == Core::KeyCode.Enter ) ||
( KeyHandler.Code == Core::KeyCode.Ok ))
Now let me focus on your second question. You would like to test whether the user has pressed an alpha or digit key. With the filter condition Core::KeyCode.AlphaOrDigitKeys you limit the affected handler to be able to react to keyboard events caused by alpha or digit keys. So far it is ok. The if-condition, as you tried to apply will however not work. Why?
When the user presses a key e.g. 8 (eight), the key handler reacts to this event since it is configured with the filter condition Core::KeyCode.AlphaOrDigitKeys. Thereupon the handler signals your slot method connected to the handler's OnPress property. While this slot method is executed you can evaluate diverse variables of the handler. These variables store the actual code of the pressed key. In this case the code for the key 8.
The variabe don't store the value of the filter condition. Thus the following condition will not work:
if ( KeyHandler.Code == Core::KeyCode.AlphaOrDigitKeys )
Instead you have to test precisely whether the variable contains the code of a particular key. You can also test whether the value of the variable lies within a given range. For this purpose you can use the variable CharCode, which contains the UNICODE character of the affected key. In this manner you can test whether the code belongs to a group of codes (e.g. alpha or digit):
if ( KeyHandler.Code == Core::KeyCode.Key8 )
trace "The user has pressed 8";
if (( KeyHandler.CharCode >= '0' ) && ( KeyHandler.CharCode <= '9' ))
trace "The user has pressed a digit key";
if (( KeyHandler.CharCode >= 'a' ) && ( KeyHandler.CharCode <= 'z' ))
trace "The user has pressed a lower letter key";
Hope it helps you further.