source: trunk/j/doc/keys.html @ 2

Last change on this file since 2 was 2, checked in by piso, 18 years ago

Initial checkin.

File size: 4.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3<html>
4
5<head>
6<title>J User's Guide - Key Mappings</title>
7<LINK REL="stylesheet" HREF="j.css" TYPE="text/css">
8</head>
9
10<body>
11
12<a href="contents.html">Top</a>
13
14<hr>
15
16<h1>Key Mappings</h1>
17
18<hr>
19
20<p>
21
22J has both global and local key maps. There is a single global key map that
23provides the default key mappings for all buffers. Each buffer also has a local
24key map that depends on the <a href="modes.html">mode</a> of the buffer. A key
25assignment defined in the local key map for a given buffer overrides any
26assignment of the same key (or key combination) in the global key map.
27<p>
28Each entry in a key map defines a binding between a "key combination" and one
29of j's commands.  A key combination may be just a single keystroke, like
30Backspace or Enter or F2.  A key combination may also involve one or more of
31the three modifier keys Ctrl, Shift and Alt, as in Shift F2 or Ctrl Alt S.
32<p>
33Every time you type a key or key combination, j begins by looking it up in the
34local key map.  If there's no entry for that key or key combination in
35the local key map, j then looks in the global key map. If it's not found
36there either, and if the key or key combination corresponds (in j's opinion) to
37a "normal" character, that character is inserted in the buffer at the
38location of the caret.
39<p>
40You can use the command <a href="commands.html#describeKey">describeKey</a>,
41mapped by default to Alt K and available on the Help menu, to see what command
42is mapped to a specific key or key combination in the current buffer.
43<p>
44Not all commands have key mappings by default. Even if a command is not mapped
45to any key or key combination, you can use still execute it with
46<a href="commands.html#executeCommand">executeCommand</a>, which is mapped by
47default to Alt X and available on the File menu ("Execute Command..."). You
48will be prompted to enter the name of the command in the location bar.
49<p>
50The commands <a href="commands.html#writeGlobalKeyMap">writeGlobalKeyMap</a> and
51<a href="commands.html#writeLocalKeyMap">writeLocalKeyMap</a> may be used to
52write out the current global or local key map, as the case may be, to a file
53you specify, as ordinary text.
54<p>
55The command <a href="commands.html#listBindings">listBindings</a>, available
56on the Help menu ("Key Bindings"), displays a list of all the key bindings in
57effect in the current buffer.
58<p>
59All of j's key assignments may be changed by the user. To replace the global
60key map, for example, add a line like this to your
61<a href="preferences.html">preferences</a> file:
62<pre>
63    globalKeyMap=/home/peter/.j/globalkeys
64</pre>
65This line instructs j to read its global key map from the specified file. This
66file must be in the format written out by
67<a href="commands.html#writeGlobalKeyMap">writeGlobalKeyMap</a> and
68<a href="commands.html#writeLocalKeyMap">writeLocalKeyMap</a>.
69<p>
70You can also replace mode-specific key maps:
71<pre>
72    JavaMode.keyMap=/home/peter/.j/javakeys
73</pre>
74If there's no entry in your preferences file for a particular key map, j will
75use its built-in defaults.
76<p>
77The easiest way to customize a key map is to write out the corresponding
78default key map using   
79<a href="commands.html#writeGlobalKeyMap">writeGlobalKeyMap</a> or   
80<a href="commands.html#writeLocalKeyMap">writeLocalKeyMap</a>, edit the
81resulting file, and then add a line to your   
82<a href="preferences.html">preferences</a> file pointing to the modified key
83map (as in the examples above).
84<p>
85Sometimes it may not be obvious what text string to use to specify a particular key
86combination.  You can use <a href="commands.html#insertKeyText">insertKeyText</a>
87to insert the appropriate text string in the key map you're editing.
88<p>
89A very small number of commands (currently only
90<a href="commands.html#insertString">insertString</a> and
91<a href="commands.html#help">help</a>, but there will be more in
92the future) require (or accept) an argument (which in the current implementation must be a
93quoted string). Such commands can be added to a key map like this:
94<pre>
95    Ctrl Alt X                      insertString("e.printStackTrace();")
96</pre>
97<p>
98Key maps can contain blank lines and comments. A comment is any line whose
99first non-whitespace character is '#'.
100<p>                               
101You can also use <a href="initialization.html">init.bsh</a> to make changes to
102the default key mappings without having to define a full set of custom key
103maps.
104
105</body>
106
107</html>
Note: See TracBrowser for help on using the repository browser.