Home   Archive   Permalink



What are some keycodes ?

Here's some code which quits a program when the escape key is pressed:
    
key keycode [#'^(ESC)'] [quit]
    
I want to do the same thing, but when the Enter key is pressed. I've tried #'^(ENT)', #'^(ENTER)', and #'^(RETURN)', but they don't work.
    
Is there a way to find out all the possible keycodes or make my own ?
    
Thanks

posted by:   Andrew       12-Apr-2017/16:50:59-7:00



The magic code for ENTER is ^M
    
    
     view layout [
     box 100x200
     key keycode [#"^M"] [print "enter pressed"]
     ]
    
You can see what codes are generated with this:
     view/new layout [
         the-box: box "A Box" forest feel [
             engage: func [face action event] [
                 print [action mold event/key]
             ]
         ]
     ]
     focus the-box
     do-events
    
Which was adapted from here: http://www.rebol.com/how-to/feel.html#section-11

posted by:   Sunanda       13-Apr-2017/3:12:07-7:00



The keycode for backspace is ^H is is the same as control h. Would it be possible to make a keycode #"^(BACK)" just like the keycode for escape, #"^(ESC)" ? Same with changing enter to #"^(ENTER) or something. That way ^M and ^H can be used when the user wants to use control m and control h.

posted by:   Andrew       27-Apr-2017/20:28:38-7:00