1. function keys identification

Is there a way to tell the difference between function key F2 and the 
letter q and F3 and the letter r? and so on?
I want to use the function keys to execute  procedures but they also get 
executed when I hit the corresponding letter...not good.

george

new topic     » topic index » view message » categorize

2. Re: function keys identification

George Walters wrote:

> Is there a way to tell the difference between function key F2 and the 
> letter q and F3 and the letter r? and so on?

Yes.

We'd need to know what platform, OS, etc., you're using to give you more
than that.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

3. Re: function keys identification

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks, I'm using windows (win32lib 59.1)<br>
<br>
I'm using these to trap keystrokes<br>
<br>
setHandler(Screen, w32HKeyPress, routine_id("keyPressProcessB"))<br>
setHandler(Screen, w32HKeyDown, routine_id("keyPressProcessA"))<br>
<br>
george<br>
<br>
<br>
cklester wrote:
<blockquote cite="mid1330855558-1463792382-1096482410 at boing.topica.com"
 type="cite">


George Walters wrote:

  </pre>
  <blockquote type="cite">
<pre wrap="">Is there a way to tell the difference between function key F2
    and the
letter q and F3 and the letter r? and so on?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Yes.

We'd need to know what platform, OS, etc., you're using to give you more
than that.

-=ck
"Programming in a state of EUPHORIA."
<a class="moz-txt-link-freetext"
href="http://www.cklester.com/euphoria/">http://www.cklester.com/euphoria/</a>





  </pre>
</blockquote>
</body>
</html>

new topic     » goto parent     » topic index » view message » categorize

4. Re: function keys identification

George Walters wrote:
> 
> Is there a way to tell the difference between function key F2 and the 
> letter q and F3 and the letter r? and so on?
> I want to use the function keys to execute  procedures but they also get 
> executed when I hit the corresponding letter...not good.

The KeyDown and KeyUp events return a KeyCode which is not always the
same as the ASCII value of the key you pressed. KeyPress does similar
but it only fires for normal keys and not function keys.

Here is some sample code that might help you see this happening.

--------------------
include win32lib.ew
without warning

constant
   Win = create( Window, "test", 0, Default, Default, 400, 300, 0 ),
   Stat = create( StatusBar, "Status", Win, 0, 0, 0, 0, 0 )

constant KEYCODES = {
     VK_LBUTTON
   , VK_RBUTTON
   , VK_CANCEL
   , VK_MBUTTON
   , VK_XBUTTON1
   , VK_XBUTTON2
   , VK_BACK
   , VK_BACKSPACE
   , VK_TAB
   , VK_CLEAR
   , VK_RETURN
   , VK_ENTER
   , VK_SHIFT
   , VK_CONTROL
   , VK_MENU
   , VK_PAUSE
   , VK_CAPITAL
   , VK_KANA
   , VK_HANGEUL
   , VK_HANGUL
   , VK_JUNJA
   , VK_FINAL
   , VK_HANJA
   , VK_KANJI
   , VK_ESCAPE
   , VK_CONVERT
   , VK_NONCONVERT
   , VK_ACCEPT
   , VK_MODECHANGE
   , VK_SPACE
   , VK_PRIOR
   , VK_PAGEUP
   , VK_NEXT
   , VK_PAGEDOWN
   , VK_END
   , VK_HOME
   , VK_LEFT
   , VK_UP
   , VK_RIGHT
   , VK_DOWN
   , VK_SELECT
   , VK_PRINT
   , VK_EXECUTE
   , VK_SNAPSHOT
   , VK_INSERT
   , VK_DELETE
   , VK_HELP
   , VK_LWIN
   , VK_RWIN
   , VK_APPS
   , VK_SLEEP
   , VK_NUMPAD0
   , VK_NUMPAD1
   , VK_NUMPAD2
   , VK_NUMPAD3
   , VK_NUMPAD4
   , VK_NUMPAD5
   , VK_NUMPAD6
   , VK_NUMPAD7
   , VK_NUMPAD8
   , VK_NUMPAD9
   , VK_MULTIPLY
   , VK_ADD
   , VK_SEPARATOR
   , VK_SUBTRACT
   , VK_DECIMAL
   , VK_DIVIDE
   , VK_F1
   , VK_F2
   , VK_F3
   , VK_F4
   , VK_F5
   , VK_F6
   , VK_F7
   , VK_F8
   , VK_F9
   , VK_F10
   , VK_F11
   , VK_F12
   , VK_F13
   , VK_F14
   , VK_F15
   , VK_F16
   , VK_F17
   , VK_F18
   , VK_F19
   , VK_F20
   , VK_F21
   , VK_F22
   , VK_F23
   , VK_F24
   , VK_NUMLOCK
   , VK_SCROLL
   , VK_OEM_NEC_EQUAL
   , VK_OEM_FJ_JISHO
   , VK_OEM_FJ_MASSHOU
   , VK_OEM_FJ_TOUROKU
   , VK_OEM_FJ_LOYA
   , VK_OEM_FJ_ROYA
   , VK_LSHIFT
   , VK_RSHIFT
   , VK_LCONTROL
   , VK_RCONTROL
   , VK_LMENU
   , VK_RMENU
   , VK_BROWSER_BACK
   , VK_BROWSER_FORWARD
   , VK_BROWSER_REFRESH
   , VK_BROWSER_STOP
   , VK_BROWSER_SEARCH
   , VK_BROWSER_FAVORITES
   , VK_BROWSER_HOME
   , VK_VOLUME_MUTE
   , VK_VOLUME_DOWN
   , VK_VOLUME_UP
   , VK_MEDIA_NEXT_TRACK
   , VK_MEDIA_PREV_TRACK
   , VK_MEDIA_STOP
   , VK_MEDIA_PLAY_PAUSE
   , VK_LAUNCH_MAIL
   , VK_LAUNCH_MEDIA_SELECT
   , VK_LAUNCH_APP1
   , VK_LAUNCH_APP2
   , VK_OEM_1
   , VK_OEM_PLUS
   , VK_OEM_COMMA
   , VK_OEM_MINUS
   , VK_OEM_PERIOD
   , VK_OEM_2
   , VK_OEM_3
   , VK_OEM_4
   , VK_OEM_5
   , VK_OEM_6
   , VK_OEM_7
   , VK_OEM_8
   , VK_OEM_AX
   , VK_OEM_102
   , VK_ICO_HELP
   , VK_ICO_00
   , VK_PROCESSKEY
   , VK_ICO_CLEAR
   , VK_PACKET
   , VK_OEM_RESET
   , VK_OEM_JUMP
   , VK_OEM_PA1
   , VK_OEM_PA2
   , VK_OEM_PA3
   , VK_OEM_WSCTRL
   , VK_OEM_CUSEL
   , VK_OEM_ATTN
   , VK_OEM_FINISH
   , VK_OEM_COPY
   , VK_OEM_AUTO
   , VK_OEM_ENLW
   , VK_OEM_BACKTAB
   , VK_ATTN
   , VK_CRSEL
   , VK_EXSEL
   , VK_EREOF
   , VK_PLAY
   , VK_ZOOM
   , VK_NONAME
   , VK_PA1
   , VK_OEM_CLEAR
}

constant KEYNAMES = {
   "VK_LBUTTON",
   "VK_RBUTTON",
   "VK_CANCEL",
   "VK_MBUTTON",
   "VK_XBUTTON1",
   "VK_XBUTTON2",
   "VK_BACK",
   "VK_BACKSPACE",
   "VK_TAB",
   "VK_CLEAR",
   "VK_RETURN",
   "VK_ENTER",
   "VK_SHIFT",
   "VK_CONTROL",
   "VK_MENU",
   "VK_PAUSE",
   "VK_CAPITAL",
   "VK_KANA",
   "VK_HANGEUL",
   "VK_HANGUL",
   "VK_JUNJA",
   "VK_FINAL",
   "VK_HANJA",
   "VK_KANJI",
   "VK_ESCAPE",
   "VK_CONVERT",
   "VK_NONCONVERT",
   "VK_ACCEPT",
   "VK_MODECHANGE",
   "VK_SPACE",
   "VK_PRIOR",
   "VK_PAGEUP",
   "VK_NEXT",
   "VK_PAGEDOWN",
   "VK_END",
   "VK_HOME",
   "VK_LEFT",
   "VK_UP",
   "VK_RIGHT",
   "VK_DOWN",
   "VK_SELECT",
   "VK_PRINT",
   "VK_EXECUTE",
   "VK_SNAPSHOT",
   "VK_INSERT",
   "VK_DELETE",
   "VK_HELP",
   "VK_LWIN",
   "VK_RWIN",
   "VK_APPS",
   "VK_SLEEP",
   "VK_NUMPAD0",
   "VK_NUMPAD1",
   "VK_NUMPAD2",
   "VK_NUMPAD3",
   "VK_NUMPAD4",
   "VK_NUMPAD5",
   "VK_NUMPAD6",
   "VK_NUMPAD7",
   "VK_NUMPAD8",
   "VK_NUMPAD9",
   "VK_MULTIPLY",
   "VK_ADD",
   "VK_SEPARATOR",
   "VK_SUBTRACT",
   "VK_DECIMAL",
   "VK_DIVIDE",
   "VK_F1",
   "VK_F2",
   "VK_F3",
   "VK_F4",
   "VK_F5",
   "VK_F6",
   "VK_F7",
   "VK_F8",
   "VK_F9",
   "VK_F10",
   "VK_F11",
   "VK_F12",
   "VK_F13",
   "VK_F14",
   "VK_F15",
   "VK_F16",
   "VK_F17",
   "VK_F18",
   "VK_F19",
   "VK_F20",
   "VK_F21",
   "VK_F22",
   "VK_F23",
   "VK_F24",
   "VK_NUMLOCK",
   "VK_SCROLL",
   "VK_OEM_NEC_EQUAL",
   "VK_OEM_FJ_JISHO",
   "VK_OEM_FJ_MASSHOU",
   "VK_OEM_FJ_TOUROKU",
   "VK_OEM_FJ_LOYA",
   "VK_OEM_FJ_ROYA",
   "VK_LSHIFT",
   "VK_RSHIFT",
   "VK_LCONTROL",
   "VK_RCONTROL",
   "VK_LMENU",
   "VK_RMENU",
   "VK_BROWSER_BACK",
   "VK_BROWSER_FORWARD",
   "VK_BROWSER_REFRESH",
   "VK_BROWSER_STOP",
   "VK_BROWSER_SEARCH",
   "VK_BROWSER_FAVORITES",
   "VK_BROWSER_HOME",
   "VK_VOLUME_MUTE",
   "VK_VOLUME_DOWN",
   "VK_VOLUME_UP",
   "VK_MEDIA_NEXT_TRACK",
   "VK_MEDIA_PREV_TRACK",
   "VK_MEDIA_STOP",
   "VK_MEDIA_PLAY_PAUSE",
   "VK_LAUNCH_MAIL",
   "VK_LAUNCH_MEDIA_SELECT",
   "VK_LAUNCH_APP1",
   "VK_LAUNCH_APP2",
   "VK_OEM_1",
   "VK_OEM_PLUS",
   "VK_OEM_COMMA",
   "VK_OEM_MINUS",
   "VK_OEM_PERIOD",
   "VK_OEM_2",
   "VK_OEM_3",
   "VK_OEM_4",
   "VK_OEM_5",
   "VK_OEM_6",
   "VK_OEM_7",
   "VK_OEM_8",
   "VK_OEM_AX",
   "VK_OEM_102",
   "VK_ICO_HELP",
   "VK_ICO_00",
   "VK_PROCESSKEY",
   "VK_ICO_CLEAR",
   "VK_PACKET",
   "VK_OEM_RESET",
   "VK_OEM_JUMP",
   "VK_OEM_PA1",
   "VK_OEM_PA2",
   "VK_OEM_PA3",
   "VK_OEM_WSCTRL",
   "VK_OEM_CUSEL",
   "VK_OEM_ATTN",
   "VK_OEM_FINISH",
   "VK_OEM_COPY",
   "VK_OEM_AUTO",
   "VK_OEM_ENLW",
   "VK_OEM_BACKTAB",
   "VK_ATTN",
   "VK_CRSEL",
   "VK_EXSEL",
   "VK_EREOF",
   "VK_PLAY",
   "VK_ZOOM",
   "VK_NONAME",
   "VK_PA1",
   "VK_OEM_CLEAR"
}

procedure ShowKey( integer self, integer event, sequence params )
    sequence keyname
    integer  pos

    pos = find(params[1], KEYCODES)
    if pos then
        keyname = KEYNAMES[pos]
    else
        keyname = sprintf("KeyCode=%d (%s)", {params[1], params[1]})
    end if

    if and_bits(params[2], ShiftMask) then
        keyname &= " (shift)"
    end if

    if and_bits(params[2], ControlMask) then
        keyname &= " (Ctrl)"
    end if

    if and_bits(params[2], AltMask) then
        keyname &= " (Alt)"
    end if

    if event = w32HKeyUp then
       keyname = "UP " & keyname
    else
       keyname = "DN " & keyname
    end if
    setText(Stat,keyname)
end procedure
setHandler( Screen, {w32HKeyDown, w32KeyUp}, routine_id("ShowKey") )

WinMain( Win, Normal )
--------------------



These keycode names can be found in the file w32keys.e which comes
with win32lib.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

5. Re: function keys identification

You may need to devise a function that returns scancodes aswell as keycodes.

new topic     » goto parent     » topic index » view message » categorize

6. Re: function keys identification

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Neat, thanks for the help. Problem fixed.....<br>
<br>
george<br>
<br>
Derek Parnell wrote:
<blockquote cite="mid798996147-1463747838-1096505855 at boing.topica.com"
 type="cite">


George Walters wrote:
  </pre>
  <blockquote type="cite">
<pre wrap="">Is there a way to tell the difference between function key F2
    and the
letter q and F3 and the letter r? and so on?
I want to use the function keys to execute  procedures but they also get 
executed when I hit the corresponding letter...not good.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
The KeyDown and KeyUp events return a KeyCode which is not always the
same as the ASCII value of the key you pressed. KeyPress does similar
but it only fires for normal keys and not function keys.

Here is some sample code that might help you see this happening.

&lt;eucode&gt;
--------------------
include win32lib.ew
without warning

constant
   Win = create( Window, "test", 0, Default, Default, 400, 300, 0 ),
   Stat = create( StatusBar, "Status", Win, 0, 0, 0, 0, 0 )

constant KEYCODES = {
     VK_LBUTTON
   , VK_RBUTTON
   , VK_CANCEL
   , VK_MBUTTON
   , VK_XBUTTON1
   , VK_XBUTTON2
   , VK_BACK
   , VK_BACKSPACE
   , VK_TAB
   , VK_CLEAR
   , VK_RETURN
   , VK_ENTER
   , VK_SHIFT
   , VK_CONTROL
   , VK_MENU
   , VK_PAUSE
   , VK_CAPITAL
   , VK_KANA
   , VK_HANGEUL
   , VK_HANGUL
   , VK_JUNJA
   , VK_FINAL
   , VK_HANJA
   , VK_KANJI
   , VK_ESCAPE
   , VK_CONVERT
   , VK_NONCONVERT
   , VK_ACCEPT
   , VK_MODECHANGE
   , VK_SPACE
   , VK_PRIOR
   , VK_PAGEUP
   , VK_NEXT
   , VK_PAGEDOWN
   , VK_END
   , VK_HOME
   , VK_LEFT
   , VK_UP
   , VK_RIGHT
   , VK_DOWN
   , VK_SELECT
   , VK_PRINT
   , VK_EXECUTE
   , VK_SNAPSHOT
   , VK_INSERT
   , VK_DELETE
   , VK_HELP
   , VK_LWIN
   , VK_RWIN
   , VK_APPS
   , VK_SLEEP
   , VK_NUMPAD0
   , VK_NUMPAD1
   , VK_NUMPAD2
   , VK_NUMPAD3
   , VK_NUMPAD4
   , VK_NUMPAD5
   , VK_NUMPAD6
   , VK_NUMPAD7
   , VK_NUMPAD8
   , VK_NUMPAD9
   , VK_MULTIPLY
   , VK_ADD
   , VK_SEPARATOR
   , VK_SUBTRACT
   , VK_DECIMAL
   , VK_DIVIDE
   , VK_F1
   , VK_F2
   , VK_F3
   , VK_F4
   , VK_F5
   , VK_F6
   , VK_F7
   , VK_F8
   , VK_F9
   , VK_F10
   , VK_F11
   , VK_F12
   , VK_F13
   , VK_F14
   , VK_F15
   , VK_F16
   , VK_F17
   , VK_F18
   , VK_F19
   , VK_F20
   , VK_F21
   , VK_F22
   , VK_F23
   , VK_F24
   , VK_NUMLOCK
   , VK_SCROLL
   , VK_OEM_NEC_EQUAL
   , VK_OEM_FJ_JISHO
   , VK_OEM_FJ_MASSHOU
   , VK_OEM_FJ_TOUROKU
   , VK_OEM_FJ_LOYA
   , VK_OEM_FJ_ROYA
   , VK_LSHIFT
   , VK_RSHIFT
   , VK_LCONTROL
   , VK_RCONTROL
   , VK_LMENU
   , VK_RMENU
   , VK_BROWSER_BACK
   , VK_BROWSER_FORWARD
   , VK_BROWSER_REFRESH
   , VK_BROWSER_STOP
   , VK_BROWSER_SEARCH
   , VK_BROWSER_FAVORITES
   , VK_BROWSER_HOME
   , VK_VOLUME_MUTE
   , VK_VOLUME_DOWN
   , VK_VOLUME_UP
   , VK_MEDIA_NEXT_TRACK
   , VK_MEDIA_PREV_TRACK
   , VK_MEDIA_STOP
   , VK_MEDIA_PLAY_PAUSE
   , VK_LAUNCH_MAIL
   , VK_LAUNCH_MEDIA_SELECT
   , VK_LAUNCH_APP1
   , VK_LAUNCH_APP2
   , VK_OEM_1
   , VK_OEM_PLUS
   , VK_OEM_COMMA
   , VK_OEM_MINUS
   , VK_OEM_PERIOD
   , VK_OEM_2
   , VK_OEM_3
   , VK_OEM_4
   , VK_OEM_5
   , VK_OEM_6
   , VK_OEM_7
   , VK_OEM_8
   , VK_OEM_AX
   , VK_OEM_102
   , VK_ICO_HELP
   , VK_ICO_00
   , VK_PROCESSKEY
   , VK_ICO_CLEAR
   , VK_PACKET
   , VK_OEM_RESET
   , VK_OEM_JUMP
   , VK_OEM_PA1
   , VK_OEM_PA2
   , VK_OEM_PA3
   , VK_OEM_WSCTRL
   , VK_OEM_CUSEL
   , VK_OEM_ATTN
   , VK_OEM_FINISH
   , VK_OEM_COPY
   , VK_OEM_AUTO
   , VK_OEM_ENLW
   , VK_OEM_BACKTAB
   , VK_ATTN
   , VK_CRSEL
   , VK_EXSEL
   , VK_EREOF
   , VK_PLAY
   , VK_ZOOM
   , VK_NONAME
   , VK_PA1
   , VK_OEM_CLEAR
}

constant KEYNAMES = {
   "VK_LBUTTON",
   "VK_RBUTTON",
   "VK_CANCEL",
   "VK_MBUTTON",
   "VK_XBUTTON1",
   "VK_XBUTTON2",
   "VK_BACK",
   "VK_BACKSPACE",
   "VK_TAB",
   "VK_CLEAR",
   "VK_RETURN",
   "VK_ENTER",
   "VK_SHIFT",
   "VK_CONTROL",
   "VK_MENU",
   "VK_PAUSE",
   "VK_CAPITAL",
   "VK_KANA",
   "VK_HANGEUL",
   "VK_HANGUL",
   "VK_JUNJA",
   "VK_FINAL",
   "VK_HANJA",
   "VK_KANJI",
   "VK_ESCAPE",
   "VK_CONVERT",
   "VK_NONCONVERT",
   "VK_ACCEPT",
   "VK_MODECHANGE",
   "VK_SPACE",
   "VK_PRIOR",
   "VK_PAGEUP",
   "VK_NEXT",
   "VK_PAGEDOWN",
   "VK_END",
   "VK_HOME",
   "VK_LEFT",
   "VK_UP",
   "VK_RIGHT",
   "VK_DOWN",
   "VK_SELECT",
   "VK_PRINT",
   "VK_EXECUTE",
   "VK_SNAPSHOT",
   "VK_INSERT",
   "VK_DELETE",
   "VK_HELP",
   "VK_LWIN",
   "VK_RWIN",
   "VK_APPS",
   "VK_SLEEP",
   "VK_NUMPAD0",
   "VK_NUMPAD1",
   "VK_NUMPAD2",
   "VK_NUMPAD3",
   "VK_NUMPAD4",
   "VK_NUMPAD5",
   "VK_NUMPAD6",
   "VK_NUMPAD7",
   "VK_NUMPAD8",
   "VK_NUMPAD9",
   "VK_MULTIPLY",
   "VK_ADD",
   "VK_SEPARATOR",
   "VK_SUBTRACT",
   "VK_DECIMAL",
   "VK_DIVIDE",
   "VK_F1",
   "VK_F2",
   "VK_F3",
   "VK_F4",
   "VK_F5",
   "VK_F6",
   "VK_F7",
   "VK_F8",
   "VK_F9",
   "VK_F10",
   "VK_F11",
   "VK_F12",
   "VK_F13",
   "VK_F14",
   "VK_F15",
   "VK_F16",
   "VK_F17",
   "VK_F18",
   "VK_F19",
   "VK_F20",
   "VK_F21",
   "VK_F22",
   "VK_F23",
   "VK_F24",
   "VK_NUMLOCK",
   "VK_SCROLL",
   "VK_OEM_NEC_EQUAL",
   "VK_OEM_FJ_JISHO",
   "VK_OEM_FJ_MASSHOU",
   "VK_OEM_FJ_TOUROKU",
   "VK_OEM_FJ_LOYA",
   "VK_OEM_FJ_ROYA",
   "VK_LSHIFT",
   "VK_RSHIFT",
   "VK_LCONTROL",
   "VK_RCONTROL",
   "VK_LMENU",
   "VK_RMENU",
   "VK_BROWSER_BACK",
   "VK_BROWSER_FORWARD",
   "VK_BROWSER_REFRESH",
   "VK_BROWSER_STOP",
   "VK_BROWSER_SEARCH",
   "VK_BROWSER_FAVORITES",
   "VK_BROWSER_HOME",
   "VK_VOLUME_MUTE",
   "VK_VOLUME_DOWN",
   "VK_VOLUME_UP",
   "VK_MEDIA_NEXT_TRACK",
   "VK_MEDIA_PREV_TRACK",
   "VK_MEDIA_STOP",
   "VK_MEDIA_PLAY_PAUSE",
   "VK_LAUNCH_MAIL",
   "VK_LAUNCH_MEDIA_SELECT",
   "VK_LAUNCH_APP1",
   "VK_LAUNCH_APP2",
   "VK_OEM_1",
   "VK_OEM_PLUS",
   "VK_OEM_COMMA",
   "VK_OEM_MINUS",
   "VK_OEM_PERIOD",
   "VK_OEM_2",
   "VK_OEM_3",
   "VK_OEM_4",
   "VK_OEM_5",
   "VK_OEM_6",
   "VK_OEM_7",
   "VK_OEM_8",
   "VK_OEM_AX",
   "VK_OEM_102",
   "VK_ICO_HELP",
   "VK_ICO_00",
   "VK_PROCESSKEY",
   "VK_ICO_CLEAR",
   "VK_PACKET",
   "VK_OEM_RESET",
   "VK_OEM_JUMP",
   "VK_OEM_PA1",
   "VK_OEM_PA2",
   "VK_OEM_PA3",
   "VK_OEM_WSCTRL",
   "VK_OEM_CUSEL",
   "VK_OEM_ATTN",
   "VK_OEM_FINISH",
   "VK_OEM_COPY",
   "VK_OEM_AUTO",
   "VK_OEM_ENLW",
   "VK_OEM_BACKTAB",
   "VK_ATTN",
   "VK_CRSEL",
   "VK_EXSEL",
   "VK_EREOF",
   "VK_PLAY",
   "VK_ZOOM",
   "VK_NONAME",
   "VK_PA1",
   "VK_OEM_CLEAR"
}

procedure ShowKey( integer self, integer event, sequence params )
    sequence keyname
    integer  pos

    pos = find(params[1], KEYCODES)
    if pos then
        keyname = KEYNAMES[pos]
    else
        keyname = sprintf("KeyCode=%d (%s)", {params[1], params[1]})
    end if

    if and_bits(params[2], ShiftMask) then
        keyname &amp;= " (shift)"
    end if

    if and_bits(params[2], ControlMask) then
        keyname &amp;= " (Ctrl)"
    end if

    if and_bits(params[2], AltMask) then
        keyname &amp;= " (Alt)"
    end if

    if event = w32HKeyUp then
       keyname = "UP " &amp; keyname
    else
       keyname = "DN " &amp; keyname
    end if
    setText(Stat,keyname)
end procedure
setHandler( Screen, {w32HKeyDown, w32KeyUp}, routine_id("ShowKey") )

WinMain( Win, Normal )
--------------------
&lt;/eucode&gt;


These keycode names can be found in the file w32keys.e which comes
with win32lib.

  </pre>
</blockquote>
</body>
</html>

new topic     » goto parent     » topic index » view message » categorize

7. Re: function keys identification

unknown wrote:
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

George, 
what method do you use to read and reply to the EUForum? All this HTML
stuff is quite off putting. 

Also, you are allowed to snip out parts of the message you don't need,
especially HUGE ones.


-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

8. Re: function keys identification

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Well, I've changed the program which now works correctly for function
keys. Problem is that now when I hit Escape or Tab it Beeps. I have
returnValue(-1) everywhere which does not solve the Beep. Any Idea's
why windows is unhappy?<br>
<br>
george<br>
<br>
George Walters wrote:<br>
<blockquote cite="mid451869143-1463792126-1096544401 at boing.topica.com"
 type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
Neat, thanks for the help. Problem fixed.....<br>
  <br>
george<br>
  <br>
Derek Parnell wrote:
  <blockquote cite="mid798996147-1463747838-1096505855 at boing.topica.com"
 type="cite">posted by: Derek Parnell &lt;ddparnell at bigpond.com&gt;
George Walters wrote:
    <blockquote type="cite">
<pre wrap="">Is there a way to tell the difference between function key F2
      and the
letter q and F3 and the letter r? and so on?
I want to use the function keys to execute  procedures but they also get 
executed when I hit the corresponding letter...not good.
    </pre>
    </blockquote>
    <pre wrap=""><!---->
The KeyDown and KeyUp events return a KeyCode which is not always the
same as the ASCII value of the key you pressed. KeyPress does similar
but it only fires for normal keys and not function keys.

Here is some sample code that might help you see this happening.

&lt;eucode&gt;
--------------------
include win32lib.ew
without warning

constant
   Win = create( Window, "test", 0, Default, Default, 400, 300, 0 ),
   Stat = create( StatusBar, "Status", Win, 0, 0, 0, 0, 0 )

constant KEYCODES = {
     VK_LBUTTON
   , VK_RBUTTON
   , VK_CANCEL
   , VK_MBUTTON
   , VK_XBUTTON1
   , VK_XBUTTON2
   , VK_BACK
   , VK_BACKSPACE
   , VK_TAB
   , VK_CLEAR
   , VK_RETURN
   , VK_ENTER
   , VK_SHIFT
   , VK_CONTROL
   , VK_MENU
   , VK_PAUSE
   , VK_CAPITAL
   , VK_KANA
   , VK_HANGEUL
   , VK_HANGUL
   , VK_JUNJA
   , VK_FINAL
   , VK_HANJA
   , VK_KANJI
   , VK_ESCAPE
   , VK_CONVERT
   , VK_NONCONVERT
   , VK_ACCEPT
   , VK_MODECHANGE
   , VK_SPACE
   , VK_PRIOR
   , VK_PAGEUP
   , VK_NEXT
   , VK_PAGEDOWN
   , VK_END
   , VK_HOME
   , VK_LEFT
   , VK_UP
   , VK_RIGHT
   , VK_DOWN
   , VK_SELECT
   , VK_PRINT
   , VK_EXECUTE
   , VK_SNAPSHOT
   , VK_INSERT
   , VK_DELETE
   , VK_HELP
   , VK_LWIN
   , VK_RWIN
   , VK_APPS
   , VK_SLEEP
   , VK_NUMPAD0
   , VK_NUMPAD1
   , VK_NUMPAD2
   , VK_NUMPAD3
   , VK_NUMPAD4
   , VK_NUMPAD5
   , VK_NUMPAD6
   , VK_NUMPAD7
   , VK_NUMPAD8
   , VK_NUMPAD9
   , VK_MULTIPLY
   , VK_ADD
   , VK_SEPARATOR
   , VK_SUBTRACT
   , VK_DECIMAL
   , VK_DIVIDE
   , VK_F1
   , VK_F2
   , VK_F3
   , VK_F4
   , VK_F5
   , VK_F6
   , VK_F7
   , VK_F8
   , VK_F9
   , VK_F10
   , VK_F11
   , VK_F12
   , VK_F13
   , VK_F14
   , VK_F15
   , VK_F16
   , VK_F17
   , VK_F18
   , VK_F19
   , VK_F20
   , VK_F21
   , VK_F22
   , VK_F23
   , VK_F24
   , VK_NUMLOCK
   , VK_SCROLL
   , VK_OEM_NEC_EQUAL
   , VK_OEM_FJ_JISHO
   , VK_OEM_FJ_MASSHOU
   , VK_OEM_FJ_TOUROKU
   , VK_OEM_FJ_LOYA
   , VK_OEM_FJ_ROYA
   , VK_LSHIFT
   , VK_RSHIFT
   , VK_LCONTROL
   , VK_RCONTROL
   , VK_LMENU
   , VK_RMENU
   , VK_BROWSER_BACK
   , VK_BROWSER_FORWARD
   , VK_BROWSER_REFRESH
   , VK_BROWSER_STOP
   , VK_BROWSER_SEARCH
   , VK_BROWSER_FAVORITES
   , VK_BROWSER_HOME
   , VK_VOLUME_MUTE
   , VK_VOLUME_DOWN
   , VK_VOLUME_UP
   , VK_MEDIA_NEXT_TRACK
   , VK_MEDIA_PREV_TRACK
   , VK_MEDIA_STOP
   , VK_MEDIA_PLAY_PAUSE
   , VK_LAUNCH_MAIL
   , VK_LAUNCH_MEDIA_SELECT
   , VK_LAUNCH_APP1
   , VK_LAUNCH_APP2
   , VK_OEM_1
   , VK_OEM_PLUS
   , VK_OEM_COMMA
   , VK_OEM_MINUS
   , VK_OEM_PERIOD
   , VK_OEM_2
   , VK_OEM_3
   , VK_OEM_4
   , VK_OEM_5
   , VK_OEM_6
   , VK_OEM_7
   , VK_OEM_8
   , VK_OEM_AX
   , VK_OEM_102
   , VK_ICO_HELP
   , VK_ICO_00
   , VK_PROCESSKEY
   , VK_ICO_CLEAR
   , VK_PACKET
   , VK_OEM_RESET
   , VK_OEM_JUMP
   , VK_OEM_PA1
   , VK_OEM_PA2
   , VK_OEM_PA3
   , VK_OEM_WSCTRL
   , VK_OEM_CUSEL
   , VK_OEM_ATTN
   , VK_OEM_FINISH
   , VK_OEM_COPY
   , VK_OEM_AUTO
   , VK_OEM_ENLW
   , VK_OEM_BACKTAB
   , VK_ATTN
   , VK_CRSEL
   , VK_EXSEL
   , VK_EREOF
   , VK_PLAY
   , VK_ZOOM
   , VK_NONAME
   , VK_PA1
   , VK_OEM_CLEAR
}

constant KEYNAMES = {
   "VK_LBUTTON",
   "VK_RBUTTON",
   "VK_CANCEL",
   "VK_MBUTTON",
   "VK_XBUTTON1",
   "VK_XBUTTON2",
   "VK_BACK",
   "VK_BACKSPACE",
   "VK_TAB",
   "VK_CLEAR",
   "VK_RETURN",
   "VK_ENTER",
   "VK_SHIFT",
   "VK_CONTROL",
   "VK_MENU",
   "VK_PAUSE",
   "VK_CAPITAL",
   "VK_KANA",
   "VK_HANGEUL",
   "VK_HANGUL",
   "VK_JUNJA",
   "VK_FINAL",
   "VK_HANJA",
   "VK_KANJI",
   "VK_ESCAPE",
   "VK_CONVERT",
   "VK_NONCONVERT",
   "VK_ACCEPT",
   "VK_MODECHANGE",
   "VK_SPACE",
   "VK_PRIOR",
   "VK_PAGEUP",
   "VK_NEXT",
   "VK_PAGEDOWN",
   "VK_END",
   "VK_HOME",
   "VK_LEFT",
   "VK_UP",
   "VK_RIGHT",
   "VK_DOWN",
   "VK_SELECT",
   "VK_PRINT",
   "VK_EXECUTE",
   "VK_SNAPSHOT",
   "VK_INSERT",
   "VK_DELETE",
   "VK_HELP",
   "VK_LWIN",
   "VK_RWIN",
   "VK_APPS",
   "VK_SLEEP",
   "VK_NUMPAD0",
   "VK_NUMPAD1",
   "VK_NUMPAD2",
   "VK_NUMPAD3",
   "VK_NUMPAD4",
   "VK_NUMPAD5",
   "VK_NUMPAD6",
   "VK_NUMPAD7",
   "VK_NUMPAD8",
   "VK_NUMPAD9",
   "VK_MULTIPLY",
   "VK_ADD",
   "VK_SEPARATOR",
   "VK_SUBTRACT",
   "VK_DECIMAL",
   "VK_DIVIDE",
   "VK_F1",
   "VK_F2",
   "VK_F3",
   "VK_F4",
   "VK_F5",
   "VK_F6",
   "VK_F7",
   "VK_F8",
   "VK_F9",
   "VK_F10",
   "VK_F11",
   "VK_F12",
   "VK_F13",
   "VK_F14",
   "VK_F15",
   "VK_F16",
   "VK_F17",
   "VK_F18",
   "VK_F19",
   "VK_F20",
   "VK_F21",
   "VK_F22",
   "VK_F23",
   "VK_F24",
   "VK_NUMLOCK",
   "VK_SCROLL",
   "VK_OEM_NEC_EQUAL",
   "VK_OEM_FJ_JISHO",
   "VK_OEM_FJ_MASSHOU",
   "VK_OEM_FJ_TOUROKU",
   "VK_OEM_FJ_LOYA",
   "VK_OEM_FJ_ROYA",
   "VK_LSHIFT",
   "VK_RSHIFT",
   "VK_LCONTROL",
   "VK_RCONTROL",
   "VK_LMENU",
   "VK_RMENU",
   "VK_BROWSER_BACK",
   "VK_BROWSER_FORWARD",
   "VK_BROWSER_REFRESH",
   "VK_BROWSER_STOP",
   "VK_BROWSER_SEARCH",
   "VK_BROWSER_FAVORITES",
   "VK_BROWSER_HOME",
   "VK_VOLUME_MUTE",
   "VK_VOLUME_DOWN",
   "VK_VOLUME_UP",
   "VK_MEDIA_NEXT_TRACK",
   "VK_MEDIA_PREV_TRACK",
   "VK_MEDIA_STOP",
   "VK_MEDIA_PLAY_PAUSE",
   "VK_LAUNCH_MAIL",
   "VK_LAUNCH_MEDIA_SELECT",
   "VK_LAUNCH_APP1",
   "VK_LAUNCH_APP2",
   "VK_OEM_1",
   "VK_OEM_PLUS",
   "VK_OEM_COMMA",
   "VK_OEM_MINUS",
   "VK_OEM_PERIOD",
   "VK_OEM_2",
   "VK_OEM_3",
   "VK_OEM_4",
   "VK_OEM_5",
   "VK_OEM_6",
   "VK_OEM_7",
   "VK_OEM_8",
   "VK_OEM_AX",
   "VK_OEM_102",
   "VK_ICO_HELP",
   "VK_ICO_00",
   "VK_PROCESSKEY",
   "VK_ICO_CLEAR",
   "VK_PACKET",
   "VK_OEM_RESET",
   "VK_OEM_JUMP",
   "VK_OEM_PA1",
   "VK_OEM_PA2",
   "VK_OEM_PA3",
   "VK_OEM_WSCTRL",
   "VK_OEM_CUSEL",
   "VK_OEM_ATTN",
   "VK_OEM_FINISH",
   "VK_OEM_COPY",
   "VK_OEM_AUTO",
   "VK_OEM_ENLW",
   "VK_OEM_BACKTAB",
   "VK_ATTN",
   "VK_CRSEL",
   "VK_EXSEL",
   "VK_EREOF",
   "VK_PLAY",
   "VK_ZOOM",
   "VK_NONAME",
   "VK_PA1",
   "VK_OEM_CLEAR"
}

procedure ShowKey( integer self, integer event, sequence params )
    sequence keyname
    integer  pos

    pos = find(params[1], KEYCODES)
    if pos then
        keyname = KEYNAMES[pos]
    else
        keyname = sprintf("KeyCode=%d (%s)", {params[1], params[1]})
    end if

    if and_bits(params[2], ShiftMask) then
        keyname &amp;= " (shift)"
    end if

    if and_bits(params[2], ControlMask) then
        keyname &amp;= " (Ctrl)"
    end if

    if and_bits(params[2], AltMask) then
        keyname &amp;= " (Alt)"
    end if

    if event = w32HKeyUp then
       keyname = "UP " &amp; keyname
    else
       keyname = "DN " &amp; keyname
    end if
    setText(Stat,keyname)
end procedure
setHandler( Screen, {w32HKeyDown, w32KeyUp}, routine_id("ShowKey") )

WinMain( Win, Normal )
--------------------
&lt;/eucode&gt;


These keycode names can be found in the file w32keys.e which comes
with win32lib.

  </pre>
  </blockquote>

new topic     » goto parent     » topic index » view message » categorize

9. Re: function keys identification

I think I have turned off HTML. Let me know if NOT. It seems that this 
switch also let me see the original message to clip.

george

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu