Home > Object Pascal, OP4JS, Smart Mobile Studio > Keyboard input for Smart Mobile Studio

Keyboard input for Smart Mobile Studio

February 14, 2015 Leave a comment Go to comments

Smart Mobile Studio provides a rich and well planned out RTL. However, the RTL does take for granted that you do know you way around HTML and that you write more hands-on code than some may be comfortable with.

One question I often get is “Why doesnt the KeyDown and KeyUp events work”. Well, they do! But the law of HTML5 is that no element can accept input (or have focus) without a tabindex being set first. And since many of the standard controls that ship with the RTL dont expect keyboard input (or need keyboard input for that matter), the key-target value was not set by default.

So the solution to why the keyboard event(s) don’t fire on your TW3Panels and other containers (including forms) is quite simply that. Here is how you get keyboard events working in your form:

procedure TForm1.InitializeForm;

  // Set the key-down event
  OnKeyDown:=Procedure (sender:TObject;Key:Integer)

  // set the key-up event
  OnClick:=procedure (sender:TObject)
    if visible then

  // this makes the form a key-event target

Note: In the next update of Smart Mobile Studio, all TW3CustomControls initialize the tabindex automatically, so by default all controls will be initialized to accept keyboard input.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: