SunSolve Internal

Infodoc ID   Synopsis   Date
15890   Keyboard Mapping PSD/FAQ   2 Mar 2000

Description Top

Keyboard Frequently Asked Questions
Last updated: October 9, 1997
    
1.  What is a keyboard modifier?
2.  How do I set the Function Key escape sequence in shelltool?
3.  How do I set the Function Key escape sequence in cmdtool & textedit?
4.  How do I set the Function Key escape sequence in xterm?
5.  How do I set keyboard translations for dtterm?
6.  In Solaris 2.6, how do I setup keyboard translations for the dtterm?
7.  How do I use the F11 and F12 Function Keys?
8.  How do I use the F11 and F12 Function Keys for Solaris 2.6?
9.  How do I prevent the F1 Function Key from bringing up Help?
10. What is the recommended way to emulate a VT100 keyboard?
11. What are the commands to manipulate the keyboard in OpenWindows?
12. How do I customize the keyboard layout for all X applications?
13. What keyboard resources can be set in .Xdefaults?
14. How do I turn on keyboard Accelerators for CDE?
15. How do I turn on keyboard Accelerators for Openwindows?
16. How do I turn on Menu Accelerator keys for CDE?
17. How do I make the Back Space and Delete keys both send delete?
18. How do I change the Key rate in openwindows?
19. How do I change the delete/backspace key functionality in Dtmail?
20. How do I get my Xlib application to receive Keyboard input?
21. When I exit openwindows, my keyboard only prints garbage to the screen
22. How do I disable the L1-A key on my keyboard?
23. How do keysyms and keycodes work?
24. How do I get the Print Screen Key to work in Openwindows or CDE?
25. How do I map the Front and Open keys in CDE?
26. Where can xmodmap changes be added permanently?
27. Are there any public domain utilities that have a GUI front-end to
    xmodmap?

---------------------------------------------------------------------------

1. What is a keyboard modifier?

	Shift(CapsLock) and AltGraph (Mode_switch) are the 2 modifers
	supported by Xlib. Client applications are in charge of the other
	modifiers. 
	
	Suppose you type xmodmap -e 'keysym q = a b c d'
	
	q will give          	a
	shift+q			b
	AltGraph+q		c
	Shift+AltGraph+q	d
	
	
	OR type xmodmap -e 'keycode 16 = 0x0c9 b c d'
	
	F11 will give		É  ( Which is E with an accent )
	Shift+F11		b
	AltGraph+F11		c
	Shift+AltGraph+F11	d
	
2.  How do I set the Function Key escape sequence in shelltool?

	Openwindows 3.X:
	
	This is done by modifying the .ttyswrc file in your home directory. 
	This file allows you to attach text, including escape codes to Function 
	Keys. The format of the .ttyswrc file is:
	
	#				Starts a comment line
	mapi	[Key]	[text]		Inputs [text] when [key] is pressed
	mapo	[Key] 	[text]		Outputs [text] when [key] is pressed
	
	The [key] may be F2 -F10, R1-R7, R9, R11, R13, R15, L2 (Again), 
	L3 (Props), and L4(Undo) as the [key]. There are no provisions for 
	shifted and unshifted function keys. The shift state is ignored.
	
	The [text] may contain escape strings such as \E for escape, \n for 
	newline, ^X for Control-X.
	
	mapi will send the [text] out to the application as if the text were 
	sent via the keyboard. This is what you would want to use if you wanted 
	to map an escape sequence to a Function Key.
	
	mapo will send the [text] to the tty as if it were sent out from the
	application. This is useful when you want to set things on the tty line
	such as the cursor position. It is not as common as mapi.
	
	A sample .ttyswrc file is in $OPENWINHOME/lib/.ttyswrc.
	
        Example:
            
              To map F5 key to send out <ESC>[228z the following line
              would be in .ttyswrc
              
                 mapi F5	\E[228z
                 
3. How do I set the Function Key escape sequence in cmdtool & textedit?

	This is done by modifying the .textswrc file in your home directory.
        The file allows you to attach filters to Function Keys. Filters are
        really just programs that are run, so you can use /usr/bin/echo to
        send out the escape code. The format of the .textswrc file is:

                [key-name]      FILTER     
                [command-line]

        The [key-name] is a string signifying the area on the keyboard where
        the Function Key resides. It is either KEY_TOP(xx) for the Fxx keys,
        KEY_LEFT(xx) for the Lxx keys, or KEY_RIGHT(xx) for the Rxx keys.

        The F2-F10, R1-R7, R9, R11, R13, R15, L2, L3, L4 may be used in the
        .textswrc file. There are no provisions for shifted and unshifted
        function keys. The shift state is ignored.

        The [command-line] is the command you would type to send out
        the escape code. /usr/bin/echo would be good for this purpose.

        For openwindows 3.0, a sample .textswrc file is located in 
        /usr/lib/textswrc. For openwindows 3.4 and above the .textswrc file
        is located in /usr/openwin/share/src/xview/examples/textsw/textswrc.

        Example1
                To map the F5 key to send out <ESC>[228z, you would put
                the following two lines in .textswrc

                        KEY_TOP(5)      FILTER
                        /usr/bin/echo "\033[228z\c"
                        
        Example2
                To map F10 Key to print the date and your name, you would put
                the following two lines in .textswrc
                
                        KEY_TOP(10)     FILTER
                        /usr/bin/echo "[ `date +%e.%b.%y` KLEIN ]\n"
                        
                        which outputs : [ 23.Sep.97 KLEIN ]

4.  How do I set the Function Key escape sequence in xterm?

    Openwindows 3.X ONLY:
    
    This is done by adding some lines to the $HOME/.Xdefaults file in
    your home directory and then running xrdb -l $HOME/.Xdefaults to reload 
    the X resources. The lines should have the following format for 
    Openwindows 3.0:

                XTerm.VT100.Translations:       #override                
[ShiftStates]<key>[KeySym]:     string([text]) \n                ...
                [ShiftStates]<key>[KeySym]:     string([text])
                
    The format for Openwindows 3.4 and above:
    
                XTerm.VT100.Translations:       #override                
[ShiftStates]<key>[KeySym]:     string([text]) \n                ...
                [ShiftStates]<key>[KeySym]:     string([text])\n
    

    The [ShiftStates] are the states of key keyboard modifiers that
    need to be in effect when they key is pressed. The values can be
    any combination of Shift, Ctrl, Meta, mod1, mod2, mod3, mod4 & mod5.
    Placing a tilde (~) in front of a modifier specifies that the modifier
    is Up or Not Pressed rather than Down or Pressed. Being able to
    specifies shift states allows the Shifted and Unshifted keys to
    be unique.

    The [KeySym] is the symbol that the key generates when it is pressed.
    This value can be retrieved by running $OPENWINHOME/demo/xev, moving
    the pointer into the window that xev creates, and pressing the desired
    keys. This will generate text in the window you started xev from. If
    you look at the text that is displayed, you will see in the some text
    like (keysym nnnn, kkkk). It is the kkkk field that is the [KeySym].
    
    The [text] field is the string that you actually want to be sent.
    it had been typed. Quotation is necessary if the string contains
    whitespace or non-alphanumeric characters. If the string argument
    begins with the characters ``0x'', it is interpreted as a hex
    character constant.
    
    To see example Xterm translations for any Openwindows see the file 
    $OPENWINHOME/lib/app-defaults/XTerm

    *********************************************************************
    Openwindows 3.0:
    Note that every line except the first and the last lines must have
    the "\n\" string appended to it. The first line needs only a "\", and
    the last line should have nothing.
    
    Openwindows 3.4 and above:
    Note that every line except the first and the last lines must have
    the "\n\" string appended to it. The first line needs only a "\", and
    the last line should have "\n".
    
    *********************************************************************
    
    Example for Openwindows 3.0:
    
                To map the F5 key to send out <ESC>[228z, you would put
                the following two lines in $HOME/.Xdefaults


                XTerm.VT100.Translations:   #override                 <Key>F5: 
                  string(0x1b) string("[228z")

    Example for Openwindows 3.4 and above:
    
    		To map the F5 key to send out <ESC>[228z, you would put
    		the following two lines in $HOME/.Xdefaults
    		
    		XTerm.VT100.Translations:   #override                 <Key>F5:           
        string(0x1b) string("[228z")\n
                
5.  How do I setup key translations for dtterms?

    Openwindows 3.4, 3.5 and 3.5.1 ONLY:
    
    dtterm uses the osf keysyms for actions/translations instead of the
    Sun-defined ones like xterm uses. 

    The order in which the key translations are done is important.
    If you are trying to get a Shift-F2 key to print "Hello"
    and the non-shifted F2 key to print "Good bye", then
    you *must* have the shifted key listed before the non-shifted key.
    
    How to map the PageUp, PageDown, Home, End, Delete, and Insert keys
    to escape sequences ?
    
    When attempting to change any key mappings for a dtterm, you can not 
    use the "#override" option for the action/translations.  You must use 
    the "#replace".
	  
	  So, the below line will not work:
	  
	  	*DtTerm*Translations:   #override 

	  But this one will:
	  
	  	*DtTerm*Translations:   #replace 


     Please refer to bug id 1232154.
     
     So, one must supply *ALL* key mappings even if you want to
     replace/modify one key.  The entire list of action/translation
     mappings can be found in the man page for DtTerm(3).
     
     It seems that using Sun's Keysyms, Prior, Next, Home, End,
     Delete, and Insert, will not work for a dtterm.  You must use 
     the osf equivalents listed below:

		Sun:		osf:
		~~~~~		~~~~~~~~~
		Prior		osfPageUp
		Next		osfPageDown
		End		osfEndLine
		Home		osfBeginLine
		Delete		osfDelete
		Insert		osfInsert

     The order in which your new key mappings are listed is important.
     If you put a non-shifted key ( <Key>osfPageUp ) before
     a shifted key ( Shift<Key>osfPageUp ), only the non-shifted
     key mapping will be used.  So, please put any multi-key 
     mappings before the non-shifted key mapping.
	  
     Below are the translations keys used with the action, "string()".


     	Shift<Key>osfPageUp:           string(" Shift osfPageUp ") \n
	Shift<Key>osfPageDown:         string(" Shift osfPageDown ") \n
	Shift<Key>osfEndLine:          string(" Shift osfEndLine ") \n
	Shift<Key>osfBeginLine:        string(" Shift osfBeginLine ") \n
	Shift<Key>osfDelete:           string(" Shift osfDelete ")\n
	Shift<Key>osfInsert:           string(" Shift osfInsert ")\n
	Shift<Key>SunF36:              string(" Shift SunF36 ") \n
	Shift<Key>SunF37:              string(" Shift SunF37 ") \n
	<Key>osfPageUp:                string(" osfPageUp ") \n
	<Key>osfPageDown:              string(" osfPageDown ") \n
	<Key>osfEndLine:               string(" osfEndLine ") \n
	<Key>osfBeginLine:             string(" osfBeginLine ") \n
	<Key>osfDelete:                string(" osfDelete ") \n
	<Key>osfInsert:                string(" osfInsert ") \n
	<Key>SunF36:                   string(" SunF36 ") \n
	<Key>SunF37:                   string(" SunF37 ") \n

    The translations can be put in either the $HOME/.Xdefaults file or in
    /usr/dt/app-config/C/DtTerm file.
	  
    The Insert key could not be mapped to anything. 
	  
    If you have used the above mappings and have gotten them to work,
    then you are ready to change the mappings to be something more useful.

    Once you've added the key translations for the dtterms into your
    .Xdefaults, run xrdb -l $HOME/.Xdefaults to reload X resouces.
    
    Sample entries can be extracted from the DtTerm man page.
    
6. In Solaris 2.6, how do I setup keyboard translations for the dtterm?

Openwindows 3.6 ONLY:

1.  If the individual wishes to make a system wide changes,:
    cp /usr/dt/app-defaults/C/Dtterm /etc/dt/app-defaults/C/Dtterm
    edit /etc/dt/app-defaults/C/Dtterm

2.  Otherwise, if the change is user-specific, edit
	$HOME/.Xdefaults

If, for example, the user wishes to have the function keys F11 and F12 echo
their escape sequences to the screen as the other function keys do, they
can do the following in either of the above files:

DtTerm*Translations:    #override\n<Key>F11:       vt-function-key-execute(11,
UDK)\n<Key>F12:       vt-function-key-execute(12, UDK)

After doing this, starting a new dtterm from the command line will pick up
these changes.  A Terminal started from the front panel or the menu will
not pick up these changes as an action is being executed.

A man on DtTerm will tell most of the functions and keys that can be defined
and what the actions are that can be used, i.e, vt-function-key-execute().

7.  How do I use the F11 and F12 Function Keys?

      For Openwindows 3.0 ONLY:

	The F11 and F12 keys are mapped to keysyms SunXK_F36 and SunXK_F37
        respectively, which are Sun defined keysyms.

        This was done for a couple of reasons. First, Standard MIT X11 only
        defines 35 Function Key keysyms. Since Sun's Type-4 keyboard contains
        37 Function Keys, it was necessary for Sun to define 2 keysyms.

        The reason F11 and F12 were selected to use the new keysyms is
        for compatibility with Sun's older Type-3 keyboards which have
        Function Keys F1-F10, L1-L10 and R1-R15. The L keys were defined
        as F11-F20 and the R keys were defined as F21-F35. Modifying this
        layout for Type-4 keyboards would have meant conditional programming
        for Type-3 and Type-4 keyboards.
        
      For Openwindows 3.4 and above:
      
        The F11 and F12 keys are mapped to keysyms SunF36 and SunF37
        respectively, which are Sun defined keysyms.

8.  How do I use the F11 and F12 Function Keys for Solaris 2.6?

    For Xterm:
    
    	If a customer wishes to make changes to the translation tables for Xterms
	for the F11 and/or F12 keys, changes need to be made to the VT100 
	Translation table.

	If this is on a system wide basis:
 	cp /usr/openwin/lib/app-defaults/XTerm
/usr/openwin/lib/app-defaults/XTerm.bak
 	edit /usr/openwin/lib/app-defaults/XTerm

	However, if this is just user-specific, he/she can edit
		$HOME/.Xdefaults

	In /usr/openwin/lib/app-defaults/XTerm, search for the string
		*VT100.Translations:    #override 	Under there, before the end of the
definition for the translations,
        place the following:
        	<Key>SunF36:    string(\^[[23~)\n        	<Key>SunF37:   
string(\^[[24~)\n
	This will actually mimic the actions of the other Fkeys when the escape
	sequences are being printed to the screen.

	After this, start another xterm to see the changes that have been made.
	
   
   For Dtterm: ( ONLY if the user is using a shell other than csh or tcsh )
   
       	1.  If the individual wishes to make a system wide changes,:
    	    cp /usr/dt/app-defaults/C/Dtterm /etc/dt/app-defaults/C/Dtterm
            edit /etc/dt/app-defaults/C/Dtterm

	2.  Otherwise, if the change is user-specific, edit
	    $HOME/.Xdefaults

	If, for example, the user wishes to have the function keys F11 and F12
	echo their escape sequences to the screen as the other function keys do,
	they can do the following in either of the above files:

	DtTerm*Translations:    #override\n	<Key>F11:       vt-function-key-execute(11,
 UDK)\n	<Key>F12:       vt-function-key-execute(12, UDK)

	After doing this, starting a new dtterm from the command line will pick up
	these changes.  A Terminal started from the front panel or the menu will
	not pick up these changes as an action is being executed.

	A man on DtTerm will tell most of the functions and keys that can be defined
	and what the actions are that can be used, i.e, vt-function-key-execute().

9.  How do I prevent the F1 Function Key from bringing up Help?

    Openwindows 3.0 and above ONLY:
    
    By default the F1 key is mapped to bring up the Help menu. If you were
    to view the syntax for it it would look like this:
    
    xmodmap -e 'keysym F1 = Help'
    
    To modify the F1 key so it isn't mapped to Help, 
    Create a file in your home directory called .xmodmaprc and place the 
    following line in there:
    
    xmodmap -e 'keysym F1 = '   <=== This disables to Help function from F1
    				     but is sets the F1 key to print out ^@
    				     
    The best thing is to have in mind a keysym that you'd like to map the F1
    key to so that way you aren't getting ^@ by disabling the Help portion.
    
    Then when you run xmodmap .xmodmaprc, the file will be read and your 
    modifications will take effect.
    
10.  What is the recommended way to emulate a VT100 keyboard?

 	xterm emulates vt100 terminal emulation. Here is a method 
        to make the keypad behave like a vt100 keypad.
	
         Modifying xterm* stuff in .Xdefaults
        
	Method:
	
	Edit the .Xdefaults in your home directory to include anything
	from /usr/openwin/lib/app-defaults/XTerm that has "VT" in it. 

    *********************************************************************
    Openwindows 3.0:
    Note that every line except the first and the last lines must have
    the "\n\" string appended to it. The first line needs only a "\", and
    the last line should have nothing.
    
    Openwindows 3.4 and above:
    Note that every line except the first and the last lines must have
    the "\n\" string appended to it. The first line needs only a "\", and
    the last line should have "\n".
    
    *********************************************************************
    
    For example:
    
    1.	*VT100.Translations:    #override 
        ....
        <Key>End: scroll-forw(100,page) \n
        
    2.  *vtMenu.*  
    
    3. *VT100*font*

11. What are the commands to manipulate the keyboard in OpenWindows?

	/usr/openwin/bin/xmodmap  - Utility for modifying keymaps in X
        /usr/openwin/bin/xset     - User preference utility for X.
                        	    Option to look for is "r".
        
        Example: "xset r 84" should change the 'a' key
                  so it does repeat.
                 "xset -r 84" should change the 'a' key
                  so it does not repeat.

        /usr/openwin/bin/kbd_mode - Change the keyboard translation mode

     Another useful command is:
     
     /usr/openwin/demo/xev - print contents of X events
     
12. How do I customize the keyboard layout for all X applications?

    You use the same commands published above under question 11.
    
13. What keyboard resources can be set in .Xdefaults?

    Resource:      OpenWindows.KeyboardCommand.*
    Resource:      OpenWindows.KeyboardCommands
    
    For details on these resources please read the man page for xview
    and look in the XView Programming Manual.
    
    For Openwindows 3.0, the rest of the Keyboard resources can be found
    in the Xview reference manual. See page#216-229.

14. How do I turn on keyboard Accelerators for CDE?

	In CDE the keyboard Accelerators are provided. See question
	16 for the default accelerator settings.	

15. How do I turn on keyboard Accelerators for Openwindows? 
   
	 Place the following resource in .Xdefaults file:
         OpenWindows.KeyboardCommands:   Full

16. How do I turn on Menu Accelerator keys for CDE?

The window menu used by default by the window manager, dtwm, is built-in
and looks like the following:

    "Restore"                   _R      Alt<Key>F5      f.normalize
    "Move"                      _M      Alt<Key>F7      f.move
    "Size"                      _S      Alt<Key>F8      f.resize
    "Minimize"                  _n      Alt<Key>F9      f.minimize
    "Maximize"                  _x      Alt<Key>F10     f.maximize
    "Lower"                     _L      Alt<Key>F3      f.lower
     no-label                                           f.separator
    "Occupy Workspace..."       _O                      f.workspace_presence
    "Occupy All Workspaces"     _A                      f.occupy_all
    "Unoccupy Workspace"        _U                      f.remove
     no-label                                           f.separator
    "Close"                     _C      Alt<Key>F4      f.kill

If you wish to use the default window menu, but change the
accelerator keys used to activate the menu items using key sequences
as opposed to using the mouse, create a menu in $HOME/.dt/dtwmrc
by a name of your choice, replacing the accelerator keys with your
desired key mappings.  Then, set the following resource:

Dtwm*windowMenu: Your_Menu_name

For example, to change the "Alt" accelerator key to the "Meta" accelerator
key, place the following entry in $HOME/.dt/dtwmrc:

Menu AcceleratorWindowMenu
{
    "Restore"                   _R      Meta<Key>R      f.normalize
    "Move"                      _M      Meta<Key>M      f.move
    "Size"                      _S      Meta<Key>S      f.resize
    "Minimize"                  _n      Meta<Key>n      f.minimize
    "Maximize"                  _x      Meta<Key>x      f.maximize
    "Lower"                     _L      Meta<Key>L      f.lower
     no-label                                           f.separator
    "Occupy Workspace..."       _O                      f.workspace_presence
    "Occupy All Workspaces"     _A                      f.occupy_all
    "Unoccupy Workspace"        _U                      f.remove
     no-label                                           f.separator
    "Close"                     _C      Meta<Key>C      f.kill
}

Then, set the following resource in $HOME/.Xdefaults:

Dtwm*windowMenu: AcceleratorWindowMenu

The new AcceleratorWindowMenu will take effect after dtwm is restarted.

17. How do I make the Back Space and Delete keys both send delete?

     xmodmap -e "keysym BackSpace = Delete"
     
     The above command should be placed into your .xmodmaprc and the 
     command xmodmap .xmodmaprc should be placed in another start up 
     file like .xinitrc. 
     
     Suppose you have the Delete key set ^? instead of actual erase.
     After typing in the xmodmap command above you know have Delete 
     and BackSpace printing out ^? characters. How do you get rid of 
     those?
     
     place in your .login/.profile the following line:
     
     stty erase '^?'
     
     Now both Delete and BackSpace erase a character.
      
18. How do I change the Key rate in openwindows?

     The command `xset r' is used to turn autorepeat ON or
     OFF (this is from the xset manpage):

     The r option controls the autorepeat.  If a  preced-
     ing  dash or the 'off' flag is used, autorepeat will
     be disabled.  If no parameters or the 'on'  flag  is
     used, autorepeat will be enabled.
     
     Below are some repeat key parameters for Xsun ONLY:

     -ar1 milliseconds
             Specify amount of  time  in  milliseconds  before  a
             pressed key begins to autorepeating.  The default is
             500 milliseconds.  This option is not  available  on
             Solaris x86 or PowerPC.

     -ar2 milliseconds
             specify  the  interval   in   milliseconds   between
             autorepeats of pressed keys.  The default is 50 mil-
             liseconds.  This option is not available on  Solaris
             x86 or PowerPC.
             
     Openwindows 3.0 ONLY:
     
     Here is what users can add/modify in their .user.ps
     file in their home directory under OpenWindows to change
     the repeat key parameters:

        UserProfile begin
        %% cause the server to wait 1/2 second before repeating keys
            /KeyRepeatThresh 1 60 div 2 div storetimeval def

        %% cause keys to repeat 10 times per second
            /KeyRepeatTime 1 60 div 10 div storetimeval def

19. How do I change the delete/backspace key functionality in Dtmail?

	In a dtmail compose window, when you hit the delete key anywhere in
	that text field the next line is concatenating onto the end rather 
	than a character being deleted. 

	In dtmail and in all text windows, the delete key deletes the character
	to the right of the cursor and backspace deletes the character to the
	left of the cursor.  When you are on the end of a line and press
	Delete, it deletes the carriage return character, thus concatenating
	the lines.  The same thing will happen if you are at the beginning of a
	line and press Backspace.

	The behavior can be modified via resources.  The resource is
	DtEditor*textTranslations and is documented in manual page DtEditor(3).
	Take a look at /usr/dt/app-defaults/C/UNIXbindings.  It redefines
	this resource.  Use it as a guideline, or use it as described in
	the comments in this file.

20. How do I get my Xlib application to receive Keyboard input?

	Keyboard input is set to a window with XSetInputFocus. The focus
        window must be viewable. For window to be viewable , it must be
        mapped and all its ancestors must be mapped, but it may be obscured.

21. When I exit openwindows, my keyboard only prints garbage to the screen

	After logging out of openwindows, typing on the console only gives me
	control characters or "garbage".  Nothing legible. 
	How can this be fixed?
	
	This generally happens when Xserver dies unexpectedly or is
	not quit gracefully.
	
	The system should still be available over the network, so issue the 
	following commands to fix the problem:

	$ telnet hostname
	login:  root
	passwd:

	# /usr/openwin/bin/kbd_mode -a >/dev/console
	# exit

	This resets the keyboard maps to translate simple ascii characters.

	From the man page:

     	kbd_mode sets the translation mode of the console's keyboard
     	(/dev/kbd)  to  one of the four values defined for KIOCTRANS
     	in kb(7).  This is useful when a  program  that  resets  the
     	translation  mode terminates abnormally and fails to restore
     	the original translation mode.

     	Note that SunView desires translated events  (kbd_mode  -e),
     	while  Xsun(1)  desires  untranslated  events (kbd_mode -u).
     	See man page for an explanation of the -e and -u options.

22. How do I disable the L1-A key on my keyboard?
    
    Openwindows 3.0 to Openwindows 3.5.1 does not have this ability.
    There is no supported way to disable the L1-A key.
    
    Solaris 2.6 offers users two ways to disable the L1-A key.
    
    1. Edit /etc/default/kbd and place the following resource in there:
        KBD_ABORT=enable|disable
        
    2. From command line: kbd -a enable|disable
    
23. How do keysyms and keycodes work?

Keycodes
--------

Each keycode represents a physical (or logical) key. They lie in the
range of [8,255]. If the physical hardware generates keycodes outside
of this range, the X server must map them with in the allowable range.
They cannot be modified by any means.

Keysyms
-------

A keysym is a code which has implied meaning. Keysyms usually come in
sets that correspond to character sets. The defined sets include
Latin-1, Latin-2, Latin-3, Latin-4, Lana, Arabic, Cryllic, Greek,
Technical, Special, Publish, Apl, Hebrew as well as a set of common
Keyboard symbols. Keysyms with the most-significant bit set (of 29
bits) are vendor-specific.

Defining Mappings
-----------------

Mappings are defined by quintuplets, one keycode and four keysyms (see
Note). Mappings can be defined with fewer than five fields, and in
these cases certain translations occur. Using "xmodmap" mappings are
defined in one of three ways:

        xmodmap <filename>
        xmodmap -e "keycode <keycode> = <keysym-list>"
        xmodmap -e "keysym  <keysym>  = <keysym-list>"

If the <keysym-list> contains fewer that four fields, the list
translates as follows:

1. If List is a Singleton, for example "K1"
   then the list is translated as "K1 NoSymbol K1 NoSymbol"

2. If List is a Pair, for example "K1 K2"
   then the list is translated as "K1 K2 K1 K2"

3. If List is a Triple, for example "K1 K2 K3"
   then the list is translated as "K1 K2 K3 NoSymbol"

If a "Null" or "Void" element is desired, the value VoidSymbol should
be used in the list.

Note: Apparently it is possible to define mappings with more than
      four keysyms associated with a keycode, but it is not clear how
      to generate the fifth or higher keysym from the keyboard.

Keysym Generation
-----------------

 KeyCode    KeySym(s)
+-------+  +-------------------------------+
| X     |  | A     | B     | A     | B     |
+-------+  +-------------------------------+
           |<---GROUP 1--->|<---GROUP 2--->|

The list of keysyms is broken up into two groups of two as pictured
above. When a key has been pressed, the keysym that is generated
depends on the three shift states Shift, Lock, and GroupModifier.
Before the keysym is generated, a couple of substitutions take place,
these are:

1. if B is NoSymbol, and A is Alphabetic
   then A = Lowercase A and B = Uppercase A

2. if B is NoSymbol, and A is NOT Alphabetic
   then B = A

After the substitutions are made, the following rules are applied to
determine which keysym to use:

1. if GroupModifier is Pressed
   then use Group 2
   else use Group 1

2. if Shift is NOT Pressed and Lock is NOT Pressed
   then use A

3. if Shift is Pressed
   then use B

4. if Lock is On and B is Uppercase Alphabetic
  then use B

5. if Lock is interpreted as Shift and Lock is On
   then use B

6. if Rules 2 through 5 have not found a keysym
   then use A

Notes
-----

The GroupModifier's keysym is Mode_switch. To use the GroupModifier,
Mode_switch must be bound to a keycode, then to a modifier (mod1
through mod5).

The good resource to determine the keycodes generated by each key is
the files in the directory $OPENWINHOME/etc/keytables. For a US Type 4
keyboard, the file would be US4.kt

Examples
--------

These examples all assume the following modifier environment:

        shift       Shift_L (0x6a),  Shift_R (0x75)
        lock        Caps_Lock (0x7e)
        mod2        Mode_switch (0x14)

And the following mappings for the keysyms:

             20         0xff7e (Mode_switch)    ! Type 4 AltGraph Key
            106         0xffe1 (Shift_L)        ! Type 4 LeftShift Key
            117         0xffe2 (Shift_R)        ! Type 4 RightShift Key
            126         0xffe5 (Caps_Lock)      ! Type 4 CapsLock Key


1. After running the command (Note: keycode 84 = A key):

        xmodmap -e "keycode 84 = A"

   The Keysym Matrix is:

                        Shift (shift)
 
                          up    down
                       +------+------+
        Group       up |  a   |  A   |
        Modifier       +------+------+
       (AltGraph) down |  a   |  A   |
                       +------+------+


2. After running the command:
  
  xmodmap -e "keycode 84 = A NoSymbol J plus"

   The Keysym Matrix is:

                        Shift (shift)
 
                          up    down
                       +------+------+
        Group       up |  a   |  A   |
        Modifier       +------+------+
 (AltGraph) down |  J   | plus |
                       +------+------+


References and Files
--------------------

"X Protocol Reference Manual", Appendix E: Keyboards and Pointers
"X11/NeWS Version 2 Server Guide", XMODMAP Manual Page ( Openwindows 3.0 )


$OPENWINHOME/etc/keytables/*.kt or $OPENWINHOME/etc/keytables/*.kt.Z for
Solaris
$OPENWINHOME/include/X11/keysymdef.h
$OPENWINHOME/include/X11/keysym.h
$OPENWINHOME/include/X11/Sunkeysym.h

man on keytable.map

srdb 3841
infodoc 15663

24. How do I get the Print Screen Key to work in Openwindows or CDE?

	The Print Screen key is on both the type 4 and type 5 Sun keyboards.
	This key serves no purpose under Openwindows and CDE. This key
	was added to Sun keyboards so they are compatible with PC software.
	For example, the Print Screen key works under Wabi. Wabi is a PC
	emmulator that allows a Sun workstation to run PC software like
	MicroSoft Word, etc... Most PC applications have built in actions
	for the Print Screen key which makes it function in a certain 
	way within an application.
	
	To make the Print Screen key work under Openwindows and CDE, you
	need to define an action for the key itself. Below are some 
	examples of how to sign an action to the Print Key within various
	applications.
	
	1. Determine what the keycode is for the Print Screen key.
	
	   xmodmap -pk | grep Print
	   29         0xffd3 (F22)    0xffd3 (F22)    0xff61 (Print)  0x1005ff60
(SunSys_Req)

           You can verify that above information is true by running the 
           xev gui and hitting the Print Screen key to obtain it's values.
           
           KeyRelease event, serial 23, synthetic NO, window 0x9800002,
    	   root 0x33, subw 0x0, time 3334056025, (113,117), root:(229,204),
           state 0x0, keycode 29 (keysym 0xffd3, F22), same_screen YES,
           XLookupString gives 0 characters:  ""

           The above two pieces of information verify that the keycode for
           Print Screen is 29
       
        2. Now map the Print Screen key to another key.
       
           Currently keysym 29 is mapped to the following:
           
           F22 F22 Print SunSys_Req
           
           Let's change that order so that we map keycode 29 to another
           function.
           
           xmodmap -e 'keycode 29 = F5 F22 Print SunSys_Req'
           
           Now if we hit the Print Screen key it will output the value 
           of the function 5 key.
          
          
       3.  Now we need to give an action to F5 so that when we hit the 
           Print Screen key it executes the action.
       
           There are a few ways to do this depending on the type of
           application you need to execute the command in.
       
           Text Fields and cmdtool:
       
           vi $HOME/.textswrc
          
            TOP_KEY(5)	FILTER
            echo hello
            
            Also see question 3.
            
            
           shelltool window:
           
           vi $HOME/.ttyswrc
           
            mapo F5 hello
                    
           Also see question 2.
           
           dtterm window:
           
           In the resource file put the following:

	   *DtTerm.Translations:   #overrideCtrl <Key>F5:   string("ls -l")\nCtrl
<Key>F8:   string("foo")
 
	   For more information look into:
	   man DtTerm 

	   (the widget class, not dtterm the executable) for more
	   information.

     	   SRDB ID: 12619

25. How do I map the Front and Open keys in CDE?

The Front and Open keys are actually controlled by the window manager 
and require special instructions to map them.

CDE instructions:

1. You need to edit the window manager resources file. Depending on
   how you're environment is setup, edit $HOME/.dt/dtwmrc or
   /etc/dt/config/C/sys.dtwmrc.

2. If you look at this file then you'll notice the preexisting settings:

    <Key>SunFront               ifkey|icon|window       f.raise_lower
    <Key>SunOpen                ifkey|window            f.minimize
    <Key>SunOpen                ifkey|icon              f.normalize

3. You can remap these by changing them to the following:

   Example: Let's say you want to map F11 to the Front key.

   <Key>SunF36		        ifkey|icon|window       f.raise_lower

   Now restart the workspace manager and the changes will take effect.

NOTE: One big draw back it that the actual Front key on Sun Keyboards 
      is no longer mapped to anything. This srdb will probably only
      be used by people who have a third party keyboard and want to
      have a key on the keyboard actually have the Front capability.

Also there are keyboard independent sequences you can use to
generate the Front and Open functionality. 

        window                  keyboard        keyboard
        function                independent     specific
        --------                -----------     --------
        raise/lower             Alt+F3          SunFront
        minimize/restore        Alt+F5          SunOpen

Please see srdb 12240 for more details.

26.  Where can xmodmap changes be added permanently?

Where can xmodmap changes be added for a permanent solution?

SOLUTION SUMMARY:

On a workstation, or X Terminal running:

    - Openwin:	make a back-up copy of the /usr/openwin/etc/keytables/US5.kt 
		file.  Then, modify this file to reflect changes to
		keysyms/keycodes

    - XDM:	make a back-up copy of the
		/usr/openwin/lib/xdm/Xsetup_0 file.  Then modify
		this file to add the desired xmodmap commands.
		Also ensure that in /usr/openwin/lib/xdm-config
		that this line is in place:

      		    DisplayManager._0.setup:  /usr/openwin/lib/xdm/Xsetup_0

    - Openwin 
      or XDM:	modify $HOME/.xinitrc to include the desired
		xmodmap commands

    - CDE: 	copy /usr/dt/config/Xsetup to /etc/dt/config/Xsetup
		(the directories under /etc may need to be created, first).
		Then modify /etc/dt/config/Xsetup to add 
		the desired xmodmap commands

On a Xterminal not running Openwin, XDM or CDE:

     - If the command "openxt" was used to bring up the window manager,
       modify $HOME/.xinitrc to include the desired xmodmap commands

     - Otherwise, run the xmodmap commands manually

27. Are there any public domain GUI front-ends to xmodmap?

Try xkeycaps, available from http://www.jwz.org/xkeycaps/

*** Sun does not support customization of X11/Openwindows/CDE. ***
Product Area Windows
Product Keyboard mapping
OS any
Hardware Sun Workstation

Top