Skip to main content
Jump to: navigation, search

Difference between revisions of "SWTBot/Keyboard Layouts"

m (using templates for creating links)
Line 1: Line 1:
= Keyboard Layouts in SWTBot =
= Keyboard Layouts in SWTBot =
Line 42: Line 43:
$ shift + 4
$ shift + 4
[[Category: SWTBot]]

Revision as of 03:35, 1 July 2009

Update Sites
Mailing List
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration

Keyboard Layouts in SWTBot


Since the changes in bug 273624: Provide native keyboard support for use with it is now possible to send native keyboard events to widgets. SWTBot provides for pluggable strategies to be able to send events to your applications. Some strategies require that they understand different types of keyboard layouts.

Why keyboard layouts are important

Assuming that CAPS LOCK is turned off, if you need to type the string 'Hello'. You need to press the following key sequence: SHIFT+H, E, L, L, O. Similarly special characters like !, #, $, :, " etc need special treatment.

The keyboard layout determines how these characters are typed on the keyboard. A SHIFT+3 on a UK keyboard represents a '#' while on a UK keyboard it represents a '£'.

How do you define your own keyboard layout ?

To define your keyboard layout either:

  • set the system property "org.eclipse.swtbot.keyboard.layout" OR
  • set the variable SWTBotPreferences#KEYBOARD_LAYOUT

The value of this property should be of the form[MAC.][upper-case-two-character-country-code]. For e.g. or The prefix ".MAC" is required for macosx keyboard.

Once you've defined the property, it is required to define the keyboard layout. For this purpose you need to create a config file called [MAC.][upper-case-two-character-country-code].keyboard in the package For e.g. com/foo/bar/US.keyboard or com/foo/bar/MAC.FR.keyboard.

See KeyboardLayoutTest for how this is defined and the folder containing the layouts for an example.

Configuration file format

Next comes the configuration file format. The file is a simple text file with the following format:


The <CHARACTER> is the complex character that needs to be typed, and the <KEY_COMBINATION> is the combination that types the <CHARACTER>. Valid <KEY_COMBINATION>s are:

  • CTRL
  • ALT
  • any other keys on the keyboard, capitalized. 'T' is valid, 't' is not. Similarly '3' on a US keyboard is valid '#' is not.

An example is:

! shift + 1
@ shift + 2
# shift + 3
$ shift + 4

Back to the top