Home   Archive   Permalink



Keypress to value


Hi,
I need to get a corresponding value from a keypress of cursor up/down. How can I do it ?

posted by:   Giuseppe Chillemi     9-Jun-2018/2:59:40-7:00



view layout [
     Txt "press a key"
     do [
         print "Installing event function"
         evtfunc: insert-event-func [
            
             if equal? event/type 'key [
                 print event/key
             ]
             if equal? event/type 'close [
                 print "Removing event function"
                 remove-event-func :evtfunc
             ]
             RETURN event
         ]
     ]
]

posted by:   aa     9-Jun-2018/11:58:59-7:00



R E B O L []
view layout [
     h3 "Press the up or down arrow key" origin
     key keycode [up] [alert "You pressed the UP arrow key"]
     key keycode [down] [alert "You pressed the DOWN arrow key"]
]

posted by:   Nick     11-Jun-2018/11:11:16-7:00



You said "get a corresponding value from a keypress of cursor up/down". Perhaps the intent is something like this?
    
R E B O L []
view layout [
    f: field 50 "0" origin
    key keycode [up] [f/text: form 1 + do f/text show f]
    key keycode [down] [f/text: form (do f/text) - 1 show f]
]

posted by:   Nick     12-Jun-2018/17:42:48-7:00