# new keyboard()
Access object to the on-screen virtual keyboard
Members
# (static) active :boolean
if the keyboard is globally active or not
Type:
- boolean
# (static) display :object
replacement strings for the special buttons on the keyboard
Type:
- object
# (static) layout :object
the default layout for the virtual keyboard
Type:
- object
# (static) selectedInput :string
a selector of the currently active element for the keyboard
Type:
- string
Methods
# (static) activate()
This gets called by the initilizer if the config sets the keyboard type to "virtual".
If not, this will not run and the keyboard stays disabled. Although it can be force enabled by calling this function
This activates the keyboard globally (if this is not run. the keyboard does not get instantiated. This is ideally done in the initialization depending on a setting)
Example
j.keyboard.activate() // Enable the virtual keyboard.
# (static) autoShow() → {void}
This runs automatically after the rendering of a page.
This function Opens the virtual keyboard if there are input fields or textareas available and closes it otherwise
Returns:
- Type
- void
Example
j.keyboard.autoShow() // This will open the keyboard if there are inputs or textareas available for it to type in. Otherwise it will close
# (static) clear()
Clear the keyboards internal value
# (static) focusElement(elem)
Tell the virtual keyboard to focus a specific element
Parameters:
Name | Type | Description |
---|---|---|
elem |
HTMLElement | the element |
# (static) getDynamicHeight() → {number}
This returns the actual pixel height of the keyboard
Returns:
- Type
- number
# (static) getInstance() → {Keyboard}
Get the keyboard
Returns:
the instance of the keyboard
- Type
- Keyboard
# (static) handleShiftButton()
This handles the shift-toggle behaviour of the keyboard
# (static) hide() → {void}
This function closes the virtual keyboard
Returns:
- Type
- void
Example
j.keyboard.hide() // if keyboard is active, it will close
# (static) initFields() → {void}
This function checks for available fields and adds listeners for the keyboard to all available inputs
Returns:
- Type
- void
# (static) onChange(input)
This is invoked when the virtual keyboards value changes
Parameters:
Name | Type | Description |
---|---|---|
input |
sting | the value |
# (static) onInputChange(event)
When the current element gets changes directly by a native keyboard, the virtual keyboards needs to update its current internal value
Parameters:
Name | Type | Description |
---|---|---|
event |
KeyboardEvent | the event |
# (static) onInputFocus(event)
This method gets called when one of the input elements is focused.
Parameters:
Name | Type | Description |
---|---|---|
event |
FocusEvent | the event |
# (static) onKeyPress(button)
This gets invoked when a button on the virtual keyboard is pressed
Parameters:
Name | Type | Description |
---|---|---|
button |
string | which button was pressed |
# (static) show() → {void}
This function Opens the virtual keyboard
Returns:
- Type
- void
Example
j.keyboard.show() // if keyboard is active but hidden, it will open
# (static) toggle() → {void}
This function toggles the virtual keyboard (close if open, open if closed)
Returns:
- Type
- void
Example
j.keyboard.toggle() // if keyboard is open, it will close. Otherwise it will be opened if it is active
# (static) updateOutlines() → {void}
Gets automatically called when focusing elements
This function adds the "active" class to the currently active input and removes it from inactive ones
Returns:
- Type
- void