source: tags/0.12.0/j/doc/keys.html

Last change on this file was 4592, checked in by piso, 21 years ago

Meta.

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