How to read key from keyboad in red/rebol

175 Views Asked by At

We can get input from console by input or ask, which means to press some keys on keyboard and terminate the input by pressing the key "Enter". I'd like to know if there is a way to get a key input, that is to say, just press a key on keyboard and then something happens, like this:

if read-key = #"a" [do something...] ;;if the key "a" on keyboard is pressed, something is done immediately--not by pressing the key "Enter" after pressing "a".

If no such any-function! like read-way in red/rebol, how to achieve it?

1

There are 1 best solutions below

5
endo64 On BEST ANSWER

On Rebol2 this should work:

>> console-port: open/binary [scheme: 'console]
>> pick console-port 1 ; hit space
== 32

>> to char! pick console-port 1  ;hit x
== #"x"