Keys in the Virtual Keyboard for JavaScript can be regular or special. A regular key sends a character or longer string as input to focused control and can display several labels (e.g. for lower and upper case letters). Its content specifies the text to send when the key is pressed. Special keys are those that do not send any character to the input element but modify the content that is sent from regular keys or affect how JsKeyboard responds to user actions: Shift, NumLock, Insert, Delete, CapsLock etc.
Keys in the virtual keyboard are represented by instances of the Key class or members of the Keys enumeration. The constructor of the Key class takes as parameter an object that provides the key code, key type, content and location. You can check the information required for a Key object in the layout.js file that is exported when you create a custom keyboard layout with the Virtual Keyboard Creator tool. Here is a sample code for two Keys:
JavaScript Copy Code |
---|
keys: |
Most of the time you would create Keys simply by using members of the Keys enumeration. Use autoRepeat to send the keyboard text multiple times when a key is pressed.
The KeyboardState enumeration let's you (de)activate special and modifier keys. It's members are static fields.
JavaScript Copy Code |
---|
KeyboardState.NumLock = true; |
JsKeyboard can have three modes: Default, Extended and Compact. You can change them using the layoutMode property. The modes are members of the KeyboardMode enumeration.
JavaScript Copy Code |
---|
vKeyboard.layoutMode = KeyboardMode.Extended; |
You can sends key's content to focused input control programmatically by calling the Key.send method. You can use the same method to simulate that a modifier, function and num-pad key was pressed:
JavaScript Copy Code |
---|
Keys.F12.send(); |
You can change the state of modifier keys with the static fields of the KeyboardState class.