Wednesday, August 12, 2009

RAD Studio 2010 - Touch Keyboard



The Touch Keyboard (TTouchKeyboard) is a new component designed specifically for touch systems. It supports a pile of languages and multi-touch. You can see the multi-touch in action in the screen shot above where I was holding down shift and pressing G. The Touch Keyboard is supported on Windows 2000, XP, Vista and Windows 7, but only Windows 7 gets multi-touch.

The Touch Keyboard is designed to be embedded in your applications where you need input from the user. Notice there is no Windows key. After much thought we decided to take a different approach to the Touch Keyboard than Microsoft did with their on screen keyboard. Our focus was on touch systems without a physical keyboard, hence the name, where Microsoft emulated the hardware keyboard.

A lot of thought was given to the colors and the font used. Touch systems are probably more likely to be used in harsh light so there needed to be a lot of contrast between the keys and the background.

31 comments:

Mode Retail Ltd said...

Can you change the colours yourself?

Chris Bensen said...

The background color can be changed with a property. The key colors currently are not so easy. Next version it will be easier but until then you can subclass the button class and do all the drawing you want of each key.

LDS said...

I see there's a caps lock key... don't tell Hodges... ;-)

Алексей Тимохин said...

Is it resizable?

Anonymous said...

What about diffrent languages

Jolyon Smith said...

What about different layouts? The Touch Keyboard control I implemented almost 10 years ago was a generic key input control that could be provided with a layout map to create just about any set of keys in any (sensible) layout you wished.

i.e. a number pad and a keyboard were the same control class, just with different layout maps.

Just curious.

Chris Bensen said...

LDS,

Hodges already brought that up... :)

Chris Bensen said...

Aleksey,

Yes, it is resizable.

Chris Bensen said...

Anonymous,

Yes, it supports many languages.

Chris Bensen said...

Jolyon,

Yes, it supports layouts. From the sound of it the implementation of your keyboard is very similar to ours. Currently there are only two layouts: Standard and NumPad. Each layout can have optional support for languages. For example, there are actually three different standard layouts: 101, 102 and 106. When the input locale is changed to say French and the Layout property is set to Standard, the Standard 102 key layout is used. The NumPad doesn't support any languages.

Next someone is going to ask if custom layouts can be created. Yes, but they aren't much fun to make.

Anonymous said...

Looks great!

Does it support asian and arabic languages as well?

Chris Bensen said...

larsdk,

Thanks. Asian is currently limited to Japanese which has the extra 6 keys but the key captions are English. We ran out of time for Chinese, Korean and Arabic.

Anonymous said...

Chris says "Next version it will be easier but until then..." So, what is the time frame for the next version?

Chris Bensen said...

Anonymous,

"Next version it will be easier but until then you can subclass the button class and do all the drawing you want of each key." It isn't exactly hard now just not as easy as changing a property.

Phil Smith said...

Since I am currently in the last stages of a Chinese project, when would be a great thing to know.

Chris Bensen said...

Phil,

Anyone can build a Chinese keyboard layout for the touch keyboard...

Anonymous said...

Chris,
...but they aren't much fun to make.
Fine, but how do you make one (I can't find any documentation about it)?

Chris Bensen said...

Anonymous,
Take a look at the units Keyboard.pas and KeyboardTypes.pas. I hope to have some time to write something about how to build these soon. So is there anything specific that you want to know?

Anonymous said...

I was just wondering if it was possible to set up a numeric keypad without the /*+- keys.
It all looks too hard at the moment - some weird format resource file required.
Thanks anyway.

Chris Bensen said...

Anonymous,

Yes it is possible but it takes some work to build the required resource file. Providing information for how to build the resource file is on my list of things to do.

Luis Madaleno said...

I am playing with it. But it need some improvements regarding languages.
It should have a public Language property so we can change the language at run-time.
In my case my machine returns "pt-PT" as the language and the resource only has "pt", so it's impossible to have a Portuguese keyboard layout.

Where is the resource file with the layouts? It would be nice to edit it.

Luis Madaleno

Chris Bensen said...

Hi Luis,

The language of the keyboard is determined by the input language of the system. Allowing the two to differ would be less than ideal.

Concerning the Portuguese keyboard layout, look at how the code works. If an exact match for "pt-PT" is not found, then the primary language is used "pt". So having "pt" as a registered keyboard layout is an all inclusive to all "pt" primary languages. You should be covered with your Portuguese keyboard layout.

The resource file is not delivered as an editable file. With my latest blog posts I'm discussing how to creating your own keyboard layouts.

Luis Madaleno said...

Thanks Chris for your answer. After some debug I found out that ti looks for a "pt" layout if it doesn't find a "pt-PT".
But I was expecting the layout to visually change the way the keys are placed. And it seems that for every language the displayed layout is always the same. For Portuguese keyboard layout I was expecting to see some special keys like "ç" others.
Like the TMS touch keyboard this one should have a Keys properties where we could edit its values individually.

Chris Bensen said...

Hi Luis,

If the keys aren't changing when you change the input language then something is wrong on your system. A little explanation for the layouts. There are three major keyboard layouts (101, 102 and 106) and one for numpad. Each input language is mapped to a layout that best matches the localized keyboard. From there the layout has tweaks for special cases. The scancodes or/or virtual code is used to let the OS handle the visual representation of the character. So a lot of languages are supported.

I'm running Windows 7 and I have a "ç" key. What operating system are you running?

Luis Madaleno said...

Hi,

I'm running Windows 7 Ultimate 64bits.
I will test this in my laptop.

mario.g said...

Hi,
I have a question about delphi keyboard touch and I want some help.Iam working on an application where I want all my forms to share a common touch keyboard.I don't want to put in every form new keyboard for its own textboxes or db grids.So I created a new form and I put the keyboard there.In every form I use a button to call the keyboard but I don't know how to link the letters that I press on it with the textboxes or db grid fields of the specific form.

Please I would like some help with that if it is possible.

Thank you

Chris Bensen said...

@marios it sounds like you want a floating keyboard? To do that you'd need to put the keyboard in a form that doesn't get focus. I have seen examples for this sort of thing. But I would suggest for usability to embed the keyboard or rework your UI to allow for this. You could put the keyboard on a frame and embed the frame or even a form and parent the form to a panel in your form.

zen said...

Hello

How creating a Form That Doesn't Take Focus in delphi ?

Please I would like some help with that if it is possible.

Thank you

boz said...

Hi Marios

Just put the 0..9 and A..Z buttons and an edit box on a form, set the captions of the buttons to the letters of the keys, lay them out how you want and set the onclick event for all the buttons to

procedure TKbdForm.ButtonClick(Sender: TObject);
begin
with sender as TButton do
edit.text := edit.Text + caption;
end;

Takes about 30 minutes to lay it all out nicely

Airogat said...

Hi Chris,
I changed the standard keyboard layouts by following your tutorial (thank you very much for this!). I would like to have a keyboard with capital letters and numbers in the number row (instead of special characters) displayed at the same time.
Therefore I replaced the scancodes of the number keys on the standard keyboard with the virtual key values of the Numpad and changed the "caps" modifier to shift. So now the keyboard should display capital letters and numbers at the same time, when capslock is pressed. This works fine. And when shift is pressed, the keyboard displays capital letters and special keys. This is also fine.
The problem now comes up when I activate capslock and shift at the same time. Then the special keys are displayed, but if I press on a button, a number is typed. Is there a way to tell the keyboard either to use shift or capslock, never both at the same time? This would probably solve my problem, but I didn't find a way to do this.
Any help would be highly appreciated!!

I also tried to only display the numbers, with the number bar not reacting neither to capslock nor to shift. I can type numbers in any constellation then, but then the problem is that with activated shift the key captions don't fit. In my case (german 102-keyboard), all of the number keys display the " ° " character repeatedly.

Chris Bensen said...

Hi Airogat,

I no longer work on Delphi or the TTouchKeyboard and don't have access to the source or remember enough off the top of my head to have a really good suggestion. The one idea I do have is you could remove the caps lock key. It's really easy to do that. But what do you replace it with?

Post a Comment