Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Graphics Administration Guide: HP 9000 Workstations and Servers > Chapter 6 X Windows Configuration Details

Customizing the Mouse and Keyboard

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This section describes the following customizations:

  • Changing mouse button actions.

  • The xmodmap client.

  • Going mouseless.

  • Customizing keyboard input.

Related information:

  • Chapter 7 contains mwm mouse and keyboard bindings.

Changing Mouse Button Actions

Normally, the mouse pointer buttons are mapped as follows:

Table 6-2 Default Mouse Button Mapping

Button Number

Button on a 2-button mouse

Button on a 3-button Mouse

Button 1

Left button

Left button

Button 2

Both buttons simultaneously

Middle button

Button 3

Right button

Right button

Button 4

Left and middle buttons simultaneously

Button 5

Middle and right buttons simultaneously

 

However, you can change these mappings. To generate buttons 4 and 5 on a three-button mouse, you must enable button chording as described later in this chapter.

Table 6-3 Alternative Mouse Button Mappings

To press:

Left-Handed Mapping

OSF/Motif Mapping

2-button mouse

3-button mouse

2-button mouse

3-button mouse

Button 1

Right button

Right button

Left button

Left button

Button 2

Both buttons simultaneously

Middle button

Right button

Middle button

Button 3

Left button

Left button

Both buttons simultaneously

Right button

Button 4

Middle and right buttons simultaneously

Left and middle buttons simultaneously

Button 5

Middle and left buttons simultaneously

Right and middle buttons simultaneously

 

The xmodmap utility can be used to change mouse button mappings. The syntax for changing mouse button mappings with xmodmap is:

xmodmap
{-e "pointer =
{default | number [number...] }" |
-pp}

Title not available (Changing Mouse Button Actions )

-e

Specifies a remapping expression. Valid expressions are covered in "Customizing Keyboard Input".

default

Set mouse keys back to default bindings.

number

Specifies a list of button numbers to map the mouse keys to. The order of the numbers refers to the original button mapping.

pp

Print the current pointer mapping.

For example, to reverse the positions of buttons 1 and 3 for left-handed mapping:

Table 6-4 Title not available (Changing Mouse Button Actions )

xmodmap -e "pointer = 3 2 1"

(2-button mouse)

xmodmap -e "pointer = 3 2 1 5 4"

(3-button mouse)

 

To establish OSF/Motif-standard button mapping:

Table 6-5 Title not available (Changing Mouse Button Actions )

xmodmap -e "pointer = 1 3 2"

2-button mouse

xmodmap -e "pointer = 1 3 2 4 5"

3-button mouse

 

Going Mouseless with the X*pointerkeys File

Your work situation may lack sufficient desk space to adequately use a mouse pointer. You may, therefore, want to "go mouseless" by naming the keyboard (or some other input device) as the pointer.

To go mouseless, you need to have the proper configuration specified in the X*devices file and to have a special configuration file named X*pointerkeys. The default X*pointerkeys file is X0pointerkeys in /usr/lib/X11.

The X*pointerkeys file lets you specify:

  • The keys that move the pointer.

  • The keys that act as pointer buttons.

  • The increments for movement of the pointer.

  • The key sequence that resets X11.

  • The pixel threshold that must be exceeded before the server switches screens.

  • That button chording is enabled or disabled.

  • That button latching is enabled or disabled.

  • Tablet subsetting.

  • Screen switching behavior for multi-screen configurations.

If you modify a X*pointerkeys file, it does not take effect until you restart the X server.

Configuring X*devices for Mouseless Operation

If you have only one keyboard and no pointer device, and you want the keyboard to serve as both keyboard and pointer, you don't have to change the default configuration of X0devices. The default input device configuration automatically assigns the pointer to the keyboard if a pointer can't be opened by the server.

If you have two or more input devices, you may need to explicitly specify which device should be the keyboard and which the pointer.

The Default Values for the X*pointerkeys File

By default, when you configure your keyboard as the pointer, the X server chooses certain number pad keys and assigns them mouse operations. Some number pad keys are assigned to pointer movement; other number pad keys are assigned to button operations.

If you don't need to change the pointer keys from their default specifications, you don't need to do anything else to use your keyboard as both keyboard and pointer. However, if you need to change the default pointer keys, you must edit the X0pointerkeys file or create a new X*pointerkeys file. The X*pointerkeys file is the file that specifies which keys are used to move the pointer when you use the keyboard as the pointer.

The default key assignments are listed in the tables in the following section on customizing the X*pointerkeys file.

Creating a Custom X*pointerkeys File

You need to modify the existing X0pointerkeys file only if one or more of the following statements are true:

  • You want to use the keyboard for a pointer.

  • You want to change the pointer keys from their default configuration.

  • You use the X0screens file to configure your display.

You need to create a custom X*pointerkeys file only if the following statements are true:

  • You want to use the keyboard for a pointer.

  • You want to change the pointer keys from their default configuration.

  • You use a configuration file other than the X0screens file to configure your display.

Syntax

You assign a keyboard key to a mouse function (pointer movement or button operation) by inserting a line in the X*pointerkeys file. Lines in the X*pointerkeys file have the syntax:

function〉 〈keyname〉 [#comment〉]

Assigning Mouse Functions to Keyboard Keys

You can assign any mouse function, either a pointer movement or a button operation, to any keyboard key. However, make sure that the key you are assigning doesn't already serve a vital function.

You can assign keyboard keys to pointer directions by specifying options in an X*pointerkeys file. The following table lists the pointer movement options, the X*pointerkeys functions that control them, and their default values:

Table 6-6 Pointer Movement Functions

Movement Option

Function

Default Key

Move the pointer to the left.

pointer_left_key

keypad_1

Move the pointer to the right.

pointer_right_key

keypad_3

Move the pointer up.

pointer_up_key

keypad_5

Move the pointer down.

pointer_down_key

keypad_2

Add a modifier key to the pointer direction keys.

pointer_key_mod1

(no default)

Add a second modifier key to the pointer direction keys.

pointer_key_mod2

(no default)

Add a third modifier key to the pointer direction keys.

pointer_key_mod3

(no default)

 

Note that the pointer direction keys are the keypad number keys on the right side of the keyboard, not the keyboard number keys above the text character keys.

You can assign keyboard keys to pointer distances by specifying options in a X0pointerkeys file. The following table lists the options that determine the distance of pointer movements, the X*pointerkeys functions that control them, and their default value:

Table 6-7 Pointer Distance Functions

Movement

Function

Default

Move the pointer a number of pixels

pointer_move

10 pixels

Move the pointer using a modifier key

pointer_mod1_amt

40 pixels

Move the pointer using a modifier key

pointer_mod2_amt

1 pixel

Move the pointer using a modifier key

pointer_mod3_amt

5 pixels

Add a modifier to the distance keys

pointer_amt_mod1

no default

Add a modifier to the distance keys

pointer_amt_mod2

no default

Add a modifier to the distance keys

pointer_amt_mod3

no default

 

You can assign keyboard keys to mouse button operations by specifying options in a X*pointerkeys file. The following table lists the button operations, the X*pointerkeys functions that control them, and their default values:

Table 6-8 Button Operation Functions

Button Operation

Function

Default Key

Perform button 1 operations

pointer_button1_key

keypad_*

Perform button 2 operations

pointer_button2_key

keypad_/

Perform button 3 operations

pointer_button3_key

keypad_+

Perform button 4 operations

pointer_button4_key

keypad_-

Perform button 5 operations

pointer_button5_key

keypad_7

 

You can change the mapping of buttons on the pointer by using options in the X*pointerkeys file. The following table lists the X*pointerkeys functions that control button mapping and their default values. Like xmodmap and xset, these functions affect only the X pointer, not any extension input devices.

Table 6-9 Button Mapping Functions

Button Mapping

Function

Default Key

Set button 1 value

button_1_value

1

Set button 2 value

button_2_value

2

Set button 3 value

button_3_value

3

Set button 4 value

button_4_value

4

Set button 5 value

button_5_value

5

 

You can change the key sequence that exits the X Window System. Also, if you use both image and overlay planes, you can change the distance you must move the pointer before you switch planes. The following table lists these options, the X*pointerkeys functions that control them, and their default values:

Table 6-10 Reset and Threshold Functions

Option

Function

Default Key

Exit the X Window System

reset

break

Add a modifier to the exit key

reset_mod1

control

Add a modifier to the exit key

reset_mod2

left_shift

Add a modifier to the exit key

reset_mod3

no default

Set the threshold for changing between screens

screen_change_amt

30 pixels (0 if a graphics tablet is used)

 

screen_change_amt is used only if your system is configured for more than one screen. screen_change_amt enables you to avoid switching from one screen to another if you accidentally run the pointer off the edge of the screen. screen_change_amt establishes a "distance threshold" that the pointer must exceed before the server switches screens. As the previous table shows, the default width of the threshold is 30 pixels, but acceptable values range from 0 to 255.

When a graphics tablet is used as the X pointer, the screen_change_amt defines an area at the left and right edges of the tablet surface that will be used to control screen changes. Moving the puck or stylus into the left or right area will cause the X server to switch to the previous or next screen.

Table 6-11 Button Chording

Option

Function

Default Action

Turn button chording off or on

button_chording

On for devices with two buttons, off for devices with more than two buttons

 

Button chording refers to the generation of a button-press by pressing two other buttons. If you have a two-button mouse, you can generate Button 3 by pressing both buttons together. With a three-button mouse, you can generate button 4 by pressing the left and middle buttons together and button 5 by pressing the middle and right buttons together. See the button chording examples in the X*pointerkeys file.

You can also use the X*pointerkeys file to configure pointer buttons so they are latched. When this feature is enabled, a button you press stays logically down until you press it again. See the example X*pointerkeys file in /usr/lib/X11 for information on configuring this functionality.

NOTE: The sample X*pointerkeys file is placed in /usr/lib/X11 at install time. If you subsequently update your system, the X*pointerkeys file in /usr/lib/X11 is not overwritten, and the sample file is placed in /usr/newconfig.

Table 6-12 Specifying a Portion of a Tablet

Option

Function

Default

Use a subset of the tablet surface as the X pointer device

tablet_subset_width tablet_subset_height tablet_subset_xorigin tablet_subset_yorigin

disabled

 

If a tablet is used as the X pointer device, it may be desirable to use only a portion of the tablet surface. A rectangular subset of the surface may be specified with these functions. The units are in millimeters from the upper left corner of the tablet surface. For example, if you want to use only an "A" size portion of a larger "B" size tablet, the following lines could be added to the X*pointerkeys file:

tablet_subset_xorigin   68
tablet_subset_yorigin 40
tablet_subset_width 296
tablet_subset_height 216

You can also use the X*pointerkeys file to control screen switching behavior in multi-screen configurations. See the example X*pointerkeys file in /usr/lib/X11 for an example of this functionality.

NOTE: The sample X*pointerkeys file is placed in /usr/lib/X11 at install time. If you subsequently update your system, the X*pointerkeys file in /usr/lib/X11 is not overwritten, and the sample file is placed in /usr/newconfig.
Modifier Keys

You can select up to three keys from among the two Shift keys, the two Extend Char keys, and the Ctrl key and use them each as modifier keys. A modifier key is a key that, when you hold it down and press another key, changes the meaning of that other key.

Modifier keys in the X*pointerkeys file have three functions:

  • They specify that a certain operation can't take place until they are pressed.

  • They enable you to adjust the distance covered by the pointer during a movement operation.

  • They enable you to change the key sequence that exits you from X11.

For example, you can overcome the problem in the last example by assigning the left Shift key as a modifier to the pointer direction keys. Now, to move the hpterm cursor to the right, you press as usual. To move the x server pointer to the right, you press left Shift .

Specifying Pointer Keys

To find out what key names are valid for the keyboard you are using, enter

xmodmap -pk

You may also use the default X Keysymbol names assigned to these keys by the X Server.

Examples

If you only have one keyboard and no mouse, and you can live with the default pointer key assignations, you don't have to do anything else to configure your system for mouseless operation. To move the pointer to the left 10 pixels, you would press the 1 key on the keypad. To press mouse button 1 you would press the * key on the keypad.

However, suppose you wanted to move only one pixel to the left. Although the default value of pointer_mod2_amt is one pixel, no key is assigned to the modifier for that amount. Thus, you would need to edit the X0pointerkeys file (or create an X*pointerkeys) to include a line assigning one of the modifier keys to pointer_amt_mod2. The following line in X0pointerkeys assigns the left Shift key to pointer_amt_mod2:

###pointerfunction key
pointer_amt_mod2 left_shift

Or suppose you wanted to set up your X0pointerkeys file so that you could move 1, 10, 25, and 100 pixels. The following lines show one way to specify this:

###pointer function      key
pointer_amt_mod1 left_extend
pointer_amt_mod2 left_shift
pointer_amt_mod3 control
pointer_move 1_pixels
pointer_mod1_amt 10_pixels
pointer_mod2_amt 25_pixels
pointer_mod3_amt 100_pixels

With these lines in effect, one press of the 1 key on the keypad moves the pointer 1 pixel to the left. Pressing the left Extend Char and 1 moves the pointer 10 pixels to the left. Pressing left Shift 1 moves the pointer 25 pixels to the left. And pressing Ctrl 1 moves the pointer 100 pixels to the left.

Or, take the case, previously mentioned, where you want to use the arrow keys for both text cursor and mouse pointer. You could insert the following lines in your X0pointerkeys file:

###pointer function      key
pointer_key_mod1 left_shift
pointer_left_key cursor_left
pointer_right_key cursor_right
pointer_up_key cursor_up
pointer_down_key cursor_down

The above lines enable you to use the arrow keys for cursor movement, while using the shifted arrow keys for pointer movement. Note that only the left Shift key (and not the right Shift) modifies the press of an arrow key from cursor to pointer movement.

Now, suppose you want to use the arrow keys to operate the pointer, and you also need the arrow keys to control the cursor in an hpterm window. Furthermore, another application uses the shift-arrow key sequence to control its cursor.

The easiest way to solve this dilemma is to call in another modifier. The following lines illustrate this. Compare them to the previous example.

###pointer function      key
pointer_key_mod1 left_shift
pointer_key_mod2 left_extend
pointer_left_key cursor_left
pointer_right_key cursor_right
pointer_up_key cursor_up
pointer_down_key cursor_down

In this example,

  • Pressing the key moves the hpterm text cursor up.

  • Pressing left Shift moves the cursor up in the program you frequently operate.

  • Pressing left Shift left Extend Char moves the pointer up.

Using a similar technique, you can also reassign the Ctrl left Shift Reset sequence that aborts a session. You can specify the press of a single key or a combination of two, three, or four key presses. Just make sure that the key sequence you select isn't something you're going to type by accident.

Customizing Keyboard Input

Besides remapping the mouse's pointer and buttons to your keyboard, you can remap any key on the keyboard to any other key.

Modifying Modifier Key Bindings with xmodmap

To change the meaning of a particular key for a particular X11 session, or to initialize the X server with a completely different set of key mappings, use the xmodmap client.

NOTE: There are two keyboards available for Hewlett-Packard workstations, the 46021 keyboard, and the C1429 keyboard. See "Using the Keyboards" for more information on using these keyboards and the differences between them.

The syntax for xmodmap is as follows:

xmodmapoptions〉 [〈filename〉]

where 〈options〉 are:

Title not available (Modifying Modifier Key Bindings with xmodmap)

-displayhost:display

Specifies the host, display number, and screen to use.

-help

Displays a brief description of xmodmap options.

-grammar

Displays a brief description of the syntax for modification expressions.

-verbose

Prints log information as xmodmap executes.

-quiet

Turns off verbose logging. This is the default.

-n

Lists changes to key mappings without actually making those changes.

-eexpression

Specifies a remapping expression to be executed.

-pm, -p

Prints the current modifier map to the standard output. This is the default.

-pk

Prints the current keymap table to the standard output.

-pp

Print the current pointer map to the standard output.

-

Specifies that the standard input should be used for the input file.

filename

Specifies a particular key mapping file to be used.

Specifying Key Remapping Expressions

Whether you remap a single key "on the fly" with a command-line entry or install an entire new keyboard map file, you must use valid expressions in your specification, one expression for each remapping.

A valid expression is any one of the following:

Table 6-13 Valid xmodmap Expressions

To do this...

Use this expression...

Assign a key symbol to a keycode

keycodekeycode=keysym

Replace a key symbol expression with another.

keysymkeysym=keysym

Clear all keys associated with a modifier key.

clearmodifier

Add a key symbol to a modifier.

addmodifier=keysym

Remove a key symbol from a modifier.

removemodifier=keysym

 

Title not available (Specifying Key Remapping Expressions )

keycode

Refers to the numerical value that uniquely identifies each key on a keyboard. Values may be in decimal, octal, or hexadecimal.

keysym

Refers to the character symbol name associated with a keycode; for example, KP_Add.

modifier

Specifies one of the eight modifier names: Shift, Control, Lock, Mod1, Mod2, Mod3, Mod4, and Mod5.

On Hewlett-Packard keyboards, the lock modifier is set to the Caps Lock key. However, any of the modifiers can be associated with any valid key symbol. Additionally, you can associate more than one key symbol with a modifier (such as Lock = Shift_R and Lock = Shift_L), and you can associate more than one modifier with a key symbol (for example, Control = Caps_Lock and Lock = Caps_Lock).

For example, on a PC-style keyboard, you can press D to print a lowercase "d", Shift D to print a capital "D", AltD to print something else, and Shift Alt D to print still something else.

The xmodmap client gives you the power to change the meaning of any key at any time or to install a whole new key map for your keyboard.

Examples

Suppose you frequently press the Caps Lock key at the most inopportune moments. You could remove the Caps Lock lock key from the lock modifier, swap it for the f1 key, then map the f1 key to the lock modifier. Do this by creating a little swapper file that contains the following lines:

!This file swaps the [Caps] key with the [F1] key.

remove Lock = Caps_Lock
keysym Caps_Lock = F1
keysym F1 = Caps_Lock
add Lock = Caps_Lock

Note the use of the ! in the file to start a comment line. To put your "swapper" file into effect, enter the following on the command line:

xmodmap swapper

If you use such a swapper file, you should probably have an unswapper file. The following file enables you to swap back to the original keyboard mapping without having to exit X11:

!This file unswaps the [F1] key with the [Caps] key.

remove Lock = Caps_Lock
keycode 88 = F1
keycode 55 = Caps_Lock
add Lock = Caps_Lock

Note the use of the hexadecimal values to reinitialize the keycodes to the proper key symbols. You put your "unswapper" file into effect by entering the following command line:

xmodmap unswapper

On a larger scale, you can change your current keyboard to a Dvorak keyboard by creating a file with the appropriate keyboard mappings.

xmodmap .keymap

Printing a Key Map

The -pk option prints a list of the key mappings for the current keyboard.

xmodmap -pk

The list contains the keycode and up to four 2-part columns. The first column contains unmodified key values, the second column contains shifted key values, the third column contains meta (Extend Char) key values, and the fourth column contains shifted meta key values. Each column is in two parts: hexadecimal key symbol value, and key symbol name.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.