It's easy, just use the key word:
view layout [
text "Press A or B keys"
key #"a" [ alert "You pressed a"]
key #"A" [alert "You pressed A"]
key keycode [#"b" #"B"] [alert "You pressed b or B"]
]
The word keycode is used for more than one key or for special keys:
view layout [
text "Press PageUp or PageDown keys"
key keycode [page-up page-down] [alert "You pressed PageUp or PageDown"]
]
The CTRL button is represented with the letter pressed and the symbol ^:
view layout [
text "Press CTRL+S"
key #"^S" [alert "You pressed CTRL+S"]
]
Special key table:
| Key | Code |
|---|---|
| Ins | insert |
| Canc | #"^~" |
| Home | home |
| End | end |
| PageUp | page-up |
| PageDown | page-down |
| Left arrow | left |
| Right arrow | right |
| Up arrow | up |
| Down arrow | down |
| Space | #" " |
| TAB | #"^-" |
| CTRL+S | #"^S" |
If you need to intercept also SHIFT with CTRL, is possible, but a little more complicated; you need to use the event:
view layout [
the-box: box "A Box" forest feel [
engage: func [face action event] [
if event/shift and (event/key = #"^S") [ print "You pressed CTRL+SIFT+S"]
]]
do [focus the-box]
]
event/shift and event/control check SHIFT and CTRL keys
No comments:
Post a Comment