keypress

Contains the last keystroke or keystroke combination made by the user in the focused item, page, or form.

A keypress option is ignored if no keypress has been established at the level of focus. If the value of a keypress option is ignored at the item level, it passes up to the page level, and if ignored at the page level, it passes up to the form level. This option allows for the creation of a default button (shortcut key) on a page or a form.

This option is not saved or transmitted as part of the form. Instead, it is automatically created each time the form is read into memory, and is maintained only during display or processing.

Syntax

   <keypress>key pressed</keypress>
Table 1. keypress parameters
Parameter Type Description
Key pressed ESC escape key
  ENTER enter key
  NUMPAD_ ENTER number pad enter key
  " " space bar
  F[1-12] function key (can be any key from F1 to F12)
  any alphanumeric char Any uppercase or lowercase alphanumeric key on the keyboard. For example 'd' or 'T'.
  ALT/CTRL[a-z/A-Z] Alt or Ctrl + any uppercase or lowercase alpha key on the keyboard. For example 'Alt + G' or 'Ctrl + q'
Notes:
  • This key combination can only be used in the Viewer. It is not supported in Webform Server .
  • Some Ctrl and Alt keypress combinations overlap with existing Viewer hot keys such as Ctrl + a. Hot key actions are evaluated before keypress options.

Available In

button, field, combobox, popup, list, radio, check, page global, form global

Example

The following example shows how you can set the keypress options to the Ctrl + G keys at the page global and global levels. When the form’s user presses the Ctrl + Shift + g keys, it activates the CancelButton’s cancel action and the text “You pressed Ctrl + G” is then displayed in the field and a save dialog box is displayed.

<button sid="CancelButton">
      <type>cancel</type>
      <value>Cancel</value>
      <custom:myoption xfdl:compute="toggle(PAGE1.global.keypress, '', 'CTRL+g') 
         == '1' ? 
         set ('CancelButton.activated','on'): ''"></custom:myoption>
      <custom:my xfdl:compute="toggle(global.global.keypress, '', 'CTRL+g') 
         == '1' ? 
         set ('FIELD1.value','You pressed Ctrl + G'): ''"></custom:my>
</button>
<label sid="FIELD1_LABEL1">          
      <itemlocation>             
         <x>3</x>             
         <y>57</y>          
      </itemlocation>          
      <value>Name</value>       
</label>
<field sid="FIELD1">
      <scrollhoriz>wordwrap</scrollhoriz>
      <value></value>
</field>

Usage details

  1. Default: none
  2. The keypress option enables the use of a default button or action on the form.
  3. You cannot place a compute in the activated option of a button. You must place it in a custom option.
  4. The keypress option is not saved or transmitted with form descriptions.