Re: get_key Processing
- Posted by jmduro Jun 18, 2016
- 1342 views
Here is what I use:
include std/console.e public constant ENTER={13}, ESC={27}, SPACE={32}, BACKSPACE = {8}, TAB = {9}, UP = {1016400}, DOWN = {1016432}, LEFT = {1016384}, RIGHT = {1016416}, PAGE_UP = {1016320}, PAGE_DOWN = {1016336}, HOME = {1016368}, CTRL_LEFT = {1024176}, START_LEFT = {1020096}, ALT = {1032400}, ALT_GR = {1020096}, START_RIGHT = {1016480}, CTXT_MENU = {1016496}, CTRL_RIGHT = {1020096}, END = {1016352}, INSERT = {1016288}, DELETE = {1016304} public constant F_ = { {1017600}, {1017616}, {1017632}, {1017648}, {1017664}, {1017680}, {1017696}, {1017712}, {1017728}, {1017744}, {1017760}, {1017776} } ------------------------------------------------------------------------------- public function getKeys() sequence result integer code result = {} code = wait_key() while code != -1 do result = append(result,code) code = get_key() end while -- printf(f_debug, "getKeys = %s\n", {sprint(result)}) return result end function
Example of usage:
atom fl_out = 0 while fl_out = 0 do ex = getKeys() if equal(ex, HOME) then -- add your code elsif equal(ex, END) then -- add your code elsif equal(ex, LEFT) then -- add your code elsif equal(ex, RIGHT) then -- add your code elsif equal(ex, DELETE) then -- add your code elsif equal(ex, INSERT) then -- add your code elsif find(ex, F_ & {UP, DOWN, ENTER, TAB, ESC}) then fl_out = 1 elsif equal(ex, BACKSPACE) then -- add your code elsif (ex[1] > 31) and (ex[1] < 255) then -- add your code end if end while
Jean-Marc