HPlogo Using the X Window System > Chapter 9 Customizing the Mouse and Keyboard

Going Mouseless with the `X*pointerkeys' File

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

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 Window System again.

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 9-3 Pointer Movement Functions.

Movement OptionFunctionDefault Key
Move the pointer to the left.pointer_left_keykeypad_1
Move the pointer to the right.pointer_right_keykeypad_3
Move the pointer up.pointer_up_keykeypad_5
Move the pointer down.pointer_down_keykeypad_2
Add a modifier key to the pointer direction keys.pointer_key_mod1no default
Add a second modifier key to the pointer direction keys. pointer_key_mod2no default
Add a third modifier key to the pointer direction keys. pointer_key_mod3no 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 9-4 Pointer Distance Functions.

MovementFunctionDefault
Move the pointer a number of pixels. pointer_move10 pixels
Move the pointer using a modifier key. pointer_mod1_amt40 pixels
Move the pointer using a modifier key. pointer_mod2_amt1 pixel
Move the pointer using a modifier key. pointer_mod3_amt5 pixels
Add a modifier to the distance keys. pointer_amt_mod1no default
Add a modifier to the distance keys. pointer_amt_mod2no default
Add a modifier to the distance keys. pointer_amt_mod3no 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 9-5 Button Operation Functions.

Button OperationFunctionDefault Key
Perform button 1 operations.pointer_button1_keykeypad_*
Perform button 2 operations.pointer_button2_keykeypad_/
Perform button 3 operations.pointer_button3_keykeypad_+
Perform button 4 operations.pointer_button4_keykeypad_-
Perform button 5 operations.pointer_button5_keykeypad_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 9-6 Button Mapping Functions.

Button MappingFunctionDefault Key
Set button 1 valuebutton_1_value1
Set button 2 valuebutton_2_value2
Set button 3 valuebutton_3_value3
Set button 4 valuebutton_4_value4
Set button 5 valuebutton_5_value5

 

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 9-7 Reset and Threshold Functions.

OptionFunctionDefault Key
Exit the X Window Systemresetbreak
Add a modifier to the exit key.reset_mod1control
Add a modifier to the exit key.reset_mod2left_shift
Add a modifier to the exit key.reset_mod3no default
Set the threshold for changing between screens.screen_change_amt30 pixels 0 if a graphics tablet is used

 

screen_change_amt is used only if your system is configured for more than one screen. (Refer to “Using Custom Screen Configurations”). 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 9-8 Button Chording

OptionFunctionDefault Action
Turn button chording off or on.button_chordingON for devices with 2 buttons, OFF for devices with >2 buttons.

 

Button chording refers to the generation of a button 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 9-9 Specifying a Portion of a Tablet

OptionFunctionDefault
Use a subset of the tablet surface as the X pointer device tablet_subset_widthdisabled
 tablet_subset_height 
 tablet_subset_xorigin 
 tablet_subset_yorigin 

 

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 right as usual. To move the x server pointer to the right, you press Left Shift right.

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 up key moves the hpterm text cursor up.

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

  • Pressing Left Shift Left Extend char up 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.

© 1995 Hewlett-Packard Development Company, L.P.