10.7 USB keyboard
Introduction
1) HMI support keyboard via USB port of HMI.
2) When the keyboard function is enabled, the “Cursor Display” function is enabled by default. The user could move the cursor through the “up, down, left and right buttons” of the keyboard, and then press the Enter key to select the object.
3) Multiple devices could be connected with HMI via USB HUB (up to 4 external devices), such as: mouse, keyboard, scanner, magnetic stripe reader, etc.
Configuration
1) Enable function
In the software [Settings menu], Click [Project settings]-> [Extend], and check [Enable keyboard] in [Input device] settings area as below shows.
2) Configuration decryption
When the keyboard function is enabled, the “Cursor Display” function is enabled by default. The user could move the cursor through the “up, down, left and right buttons” of the keyboard, and then press the Enter key to select the object;
NumLock: When NumLock key is not lit, the keypad number is not allowed to be input (offline simulation does not allow all numeric keys to be input, including the numeric keys on the left side of the keyboard);
Key combination: (1) "Shift" + the left side of the keyboard and the special symbol button, to achieve special character input, such as: ~ ! @ # $ % ^ & * ( ) _ + { } : " < > ? ;
Use the system special addresses "HSW1073 and HSW1074" to write custom key combinations in the script (currently only two key combinations are supported);
Caps Lock: In lowercase mode, shift+ letters, to enter uppercase; in uppercase mode, shift+ letters enter lowercase;
3) System special address
In practical application, the [Enable Keyboard] function could be combined with the related "system special address" to achieve multi-key combination operation.
Address | Description | Function |
HSW1073 | Keyboard key value | The currently pressed key value is displayed. The key value is shown in Table 1 (The Numeric/Character display object is not updated when it is being entered) |
HSW1074 | Keyboard key status | Display current key states =0: key release =1: key press =2: Press and hold long (The Numeric/Character display object is not updated when it is being entered) |
HSW1075 | Cursor speed | Control the movement speed of the cursor, the range is 0~100, the default is 20 |
HSW1076 | X coordinate value of cursor | The X value of the current position of the cursor, range: 0~screen width-1 |
HSW1077 | Y coordinate value of cursor | The Y value of the current position of the cursor, range: 0~screen height-1 |
HSW1078 | The ASCII code of keyboard key | Only the ASCII values of letters, numbers, and symbols are displayed. The ASCII value of the function keys is not displayed, as shown in Table 2 (The Numeric/Character display object is not updated when it is being entered) |
HSW1079 | Enable cursor position and Enter key mode | HSX1079.0 = 1: Set the cursor position according to HSW1076 and HSW1077 value; HSX1079.1 = 0: When Numeric/Character display object is entered, enter key is for end input instruction. When no Numeric/Character display object is entered, enter key is for normal click; HSX1079.1 = 1: Enter key only for normal click, not for keyboard end input instruction; |
Key-value appendix table (decimal) (104 keys)
Key | Value | Key | Value | Key | Value |
ESC | 1 | i I | 23 | Alt (Right) | 100(offline: 56) |
F1 | 59 | o O | 24 | windows(Right) | 126(offline: 125) |
F2 | 60 | p P | 25 | Menu | 127 |
F3 | 61 | [ { | 26 | Right_ctrl | 97(offline: 29) |
F4 | 62 | ] } | 27 | Print Screen | 99 |
F5 | 63 | Enter | 28 | ScrollLock | 70 |
F6 | 64 | CapsLock | 58 | PauseBreak | 119 |
F7 | 65 | a A | 30 | Insert | 110 |
F8 | 66 | s S | 31 | Home | 102 |
F9 | 67 | d D | 32 | PageUp | 104 |
F10 | 68 | f F | 33 | Delete | 111 |
F11 | 87 | g G | 34 | End | 107 |
F12 | 88 | h H | 35 | PageDown | 109 |
` ~ | 41 | j J | 36 | ↑ | 103 |
1 ! | 2 | k K | 37 | ↓ | 108 |
2 @ | 3 | l L | 38 | ← | 105 |
3 # | 4 | ; : | 39 | → | 106 |
4 $ | 5 | ' " | 40 | NumLock (Keypad) | 69 |
5% | 6 | \ | | 43 | / (Keypad) | 98 (offline 53) |
6 ^ | 7 | Shift (Left) | 42 | * (Keypad) | 55 (offline: 9) |
7 & | 8 | z Z | 44 | - (Keypad) | 74 (offline: 12) |
8 * | 9 | x X | 45 | + (Keypad) | 78 (offline: 13) |
9 ( | 10 | c C | 46 | Enter (Keypad) | 96 |
0 ) | 11 | v V | 47 | . (Keypad) | 83 (offline: 9) |
- _ | 12 | b B | 48 | 0 (Keypad) | 82 (offline: 11) |
+ = | 13 | n N | 49 | 1 (Keypad) | 79 (offline: 2) |
Backspace | 14 | m M | 50 | 2 (Keypad) | 80 (offline: 3) |
Tab | 15 | , < | 51 | 3 (Keypad) | 81 (offline: 4) |
q Q | 16 | . > | 52 | 4 (Keypad) | 75 (offline: 5) |
w W | 17 | / ? | 53 | 5 (Keypad) | 76 (offline: 6) |
e E | 18 | Shift (Right) | 54 (offline : 42) | 6 (Keypad) | 77 (offline: 7) |
r R | 19 | Ctrl (Left) | 29 | 7 (Keypad) | 71 (offline: 8) |
t T | 20 | Windows(Left) | 125 | 8 (Keypad) | 72 (offline: 9) |
Y y | 21 | Alt (Left) | 56 | 9 (Keypad) | 73 (offline: 10) |
u U | 22 | space | 57 |
ASCII code
Code | Value | Code | Value | Code | Value | Code | Value |
32 | space | 56 | 8 | 80 | P | 104 | h |
33 | ! | 57 | 9 | 81 | Q | 105 | i |
34 | " | 58 | : | 82 | R | 106 | j |
35 | # | 59 | ; | 83 | S | 107 | k |
36 | $ | 60 | < | 84 | T | 108 | l |
37 | % | 61 | = | 85 | U | 109 | m |
38 | & | 62 | > | 86 | V | 110 | n |
39 | ' | 63 | ? | 87 | W | 111 | o |
40 | ( | 64 | @ | 88 | X | 112 | p |
41 | ) | 65 | A | 89 | Y | 113 | q |
42 | * | 66 | B | 90 | Z | 114 | r |
43 | + | 67 | C | 91 | [ | 115 | s |
44 | , | 68 | D | 92 | \ | 116 | t |
45 | - | 69 | E | 93 | ] | 117 | u |
46 | . | 70 | F | 94 | ^ | 118 | v |
47 | / | 71 | G | 95 | _ | 119 | w |
48 | 0 | 72 | H | 96 | ` | 120 | x |
49 | 1 | 73 | I | 97 | a | 121 | y |
50 | 2 | 74 | J | 98 | b | 122 | z |
51 | 3 | 75 | K | 99 | c | 123 | { |
52 | 4 | 76 | L | 100 | d | 124 | | |
53 | 5 | 77 | M | 101 | e | 125 | } |
54 | 6 | 78 | N | 102 | f | 126 | ~ |
55 | 7 | 79 | O | 103 | g |
Scripts example
'HSW1073 key value
'HSW1074 key states 0: released; 1: pressed; 2: Holding pressed
'HSW1078 ASCII value of key
1) Example 1
if @W_HSW1073 = 29 then 'Ctrl key value is 29
if @W_HSW1074 = 1 or @W_HSW1074 = 2 then 'Press Ctrl key
@W_HDW1000 = 1
else 'Release Ctrl key
@W_HDW1000 = 0
endif
endif
2) Example 2
if @W_HSW1073 = 59 and (@W_HSW1074 = 1 or @W_HSW1074 = 2) then 'F1 key value is 59
if @W_HDW1000 = 1 then 'Combination Ctrl + F1
@W_HDW2000 = @W_HDW2000 + 1 'Function of combination key is HDW2000 + 1
endif
endif
3) Example 3
if @W_HSW1073 = 60 and (@W_HSW1074 = 1 or @W_HSW1074 = 2) then 'the value of F2 is 60
if @W_HDW1000 = 1 then 'Combination Ctrl + F2
@W_HDW2000 = @W_HDW2000 - 1 'Function of combination key is HDW2000 - 1
endif
endif
4) Example 4
if AsString(@W_HSW1078) = "a" and (@W_HSW1074 = 1 or @W_HSW1074 = 2) then ' Page up
if @W_HSW13 > 0 then
@W_HSW13 = @W_HSW13 - 1
endif
endif
5) Example 5
if AsString(@W_HSW1078) = "b" and (@W_HSW1074 = 1 or @W_HSW1074 = 2) then 'Page down
@W_HSW13 = @W_HSW13 + 1
if @W_HSW13 > 3 then
@W_HSW13 = 3
endif
endif
Last updated