SUMMARY: Programming Function Keys

From: Evan Hall (hall@informix.com)
Date: Thu Oct 31 1996 - 12:07:23 CST


Many thanks to all the respondents to my question especially Mike Roberts
and Raju Krishnamurthy. Here's what they said:

Evan

if you do an 'xmodmap -pk' it will list the current settings. I use
the "KeyCode value" and the "Keysym (name)" to remap the keyboard. For
example, if I wanted to remap the "F1" key to be the same as "Esc" (since
they're one above the other on a type 4 Kybd), I would do the following:

% xmodmap -pk | more
There are 4 KeySyms per KeyCode; KeyCodes range from 8 to 132.

    KeyCode Keysym (Keysym) ...
    Value Value (Name) ...

     ...

     12 0xffbe (F1)

     ...

     36 0xff1b (Escape)
     37 0x0031 (1) 0x0021 (exclam)

     ...

% xmodmap keycode 12 = Escape

--raju

and mike weighs in with this approach:

Evan,

I've had to deal with programming function keys for several applications
and it can be a 2 part process. First you have to make sure the keys
are operational. In the case of the F11 and F12 keys, they are not set
up to do anything. Your STOP and AGAIN keys on the right of the
keyboard are actually defined as your F11 and F12 key values. The keys
marked F11 and F12 have been designated SunF36 or SunXK_F36 and SunF37
or SunXK_F37 depending on the version of OpenWindows you are using. To
find out what keys are set to which values currently (such as if it
should be SunF36 or SunXK_F36), use "xmodmap -pk | more". This process
of defining the keys is done with the xmodmap -e command and can be
easily set up in the .xinitrc file.

The second part is to tell the application you are running what values
will be sent by hitting the keys. This is done in most X applications
by settin the translations resource for the application in your
.Xdefaults file. You can find the control sequence a key sends by using
the cat -v (for verbose) command inside of an xterm or a shelltool
window. Cmdtool will NOT work because it doesn't recognize function
keys anyway. Inside the cat -v, the value of any key or key combination
will be printed on the window. Do a <CNTL> d to exit the command.

This all sounds complicated but once you play with it some, there's not
that much to it. We use a product called x3270 from IBM to do telnet
3270 terminal session to our mainframe. Here are the instructions I
give out to set up the F11 and F12 keys (shifted and regular) to work as
the PF11, PF12, PF23 (shifted F11), and PF24 (shifted F12) keys. Maybe
it will help as an example.
******************************

Instructions for fixing the OpenWindows environment to allow the F11 and
   F12 keys on the Sun 5 keyboard to send the F36 and F37 keysyms for
use
   with NOS and NOS/VE screen formatting.
 
In the local .xinitrc file after the if block for xrdb, enter the
following:
 
xmodmap -e "keycode 16 = SunXK_F36" \
        -e "keycode 18 = SunXK_F37" &
 
If you are using IBM's X3270 software to connect to the IBM mainframe,
add
the following entries to your .Xdefaults file so that your F11 and F12
keys will do PF11 and PF12 functions:
 
X3270*x3270.Translations: #override \
  Shift <Key>SunXK_F36: pf23() \n\
        <Key>SunXK_F36: pf11() \n\
  Shift <Key>SunXK_F37: pf24() \n\
        <Key>SunXK_F37: pf12()
 
Remember, any changes to the .xinitrc file will not be picked up until
the next time that the window environment is started. Changes to the
.Xdefaults file may be picked up using the xrdb command which is also
run by .xinitrc during OpenWindows startup.
***************************************

Good luck,
Mike Roberts
Evan,

I've had to deal with programming function keys for several applications
and it can be a 2 part process. First you have to make sure the keys
are operational. In the case of the F11 and F12 keys, they are not set
up to do anything. Your STOP and AGAIN keys on the right of the
keyboard are actually defined as your F11 and F12 key values. The keys
marked F11 and F12 have been designated SunF36 or SunXK_F36 and SunF37
or SunXK_F37 depending on the version of OpenWindows you are using. To
find out what keys are set to which values currently (such as if it
should be SunF36 or SunXK_F36), use "xmodmap -pk | more". This process
of defining the keys is done with the xmodmap -e command and can be
easily set up in the .xinitrc file.

The second part is to tell the application you are running what values
will be sent by hitting the keys. This is done in most X applications
by settin the translations resource for the application in your
.Xdefaults file. You can find the control sequence a key sends by using
the cat -v (for verbose) command inside of an xterm or a shelltool
window. Cmdtool will NOT work because it doesn't recognize function
keys anyway. Inside the cat -v, the value of any key or key combination
will be printed on the window. Do a <CNTL> d to exit the command.

This all sounds complicated but once you play with it some, there's not
that much to it. We use a product called x3270 from IBM to do telnet
3270 terminal session to our mainframe. Here are the instructions I
give out to set up the F11 and F12 keys (shifted and regular) to work as
the PF11, PF12, PF23 (shifted F11), and PF24 (shifted F12) keys. Maybe
it will help as an example.
******************************

Instructions for fixing the OpenWindows environment to allow the F11 and
   F12 keys on the Sun 5 keyboard to send the F36 and F37 keysyms for
use
   with NOS and NOS/VE screen formatting.
 
In the local .xinitrc file after the if block for xrdb, enter the
following:
 
xmodmap -e "keycode 16 = SunXK_F36" \
        -e "keycode 18 = SunXK_F37" &
 
If you are using IBM's X3270 software to connect to the IBM mainframe,
add
the following entries to your .Xdefaults file so that your F11 and F12
keys will do PF11 and PF12 functions:
 
X3270*x3270.Translations: #override \
  Shift <Key>SunXK_F36: pf23() \n\
        <Key>SunXK_F36: pf11() \n\
  Shift <Key>SunXK_F37: pf24() \n\
        <Key>SunXK_F37: pf12()
 
Remember, any changes to the .xinitrc file will not be picked up until
the next time that the window environment is started. Changes to the
.Xdefaults file may be picked up using the xrdb command which is also
run by .xinitrc during OpenWindows startup.
***************************************

Good luck,
Mike Roberts

evan hall

Unix Sys Admin
Informix



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:14 CDT