On this page:
3.3.1 Moving Around
3.3.2 Editing Operations
3.3.3 File Operations
3.3.4 Search
3.3.5 Miscellaneous
3.3.6 Interactions
3.3.7 La Te X and Te X inspired keybindings
3.3.8 Defining Custom Shortcuts

3.3 Keyboard Shortcuts

Most key presses simply insert a character into the editor, such as a, 3, or (. Other keys and key combinations act as keyboard shortcuts that move the blinking caret, delete a line, copy the selection, etc. Keyboard shortcuts are usually trigger by key combinations using the Control, Meta, or Command key.

Many of the key-binding actions can also be performed with menu items.

C-‹key› means press the Control key, hold it down and then press ‹key› and then release them both. For example: C-e (Control-E) moves the blinking caret to the end of the current line.

M-‹key› is the same as C-‹key›, except with the Meta key. Depending on your keyboard, Meta may be called “Left,” “Right,” or have a diamond symbol, but it’s usually on the bottom row next to the space bar. M-‹key› can also be performed as a two-character sequence: first, strike and release the Escape key, then strike ‹key›. On Windows and Mac OS X, Meta is only available through the Escape key.

DEL is the Delete key.

SPACE is the Space bar.

On most keyboards, “<” and “>” are shifted characters. So, to get M->, you actually have to type Meta-Shift->. That is, press and hold down both the Meta and Shift keys, and then strike “>”.

On Windows, some of these keybindings are actually standard menu items. Those keybindings will behave according to the menus, unless the Enable keybindings in menus preference is unchecked.

If you are most familiar with Emacs-style key bindings, you should uncheck the Enable keybindings in menus preference. Many of the keybindings below are inspired by Emacs.}

3.3.1 Moving Around
3.3.2 Editing Operations
3.3.3 File Operations
3.3.4 Search
3.3.5 Miscellaneous
3.3.6 Interactions

The interactions window has all of the same keyboard shortcuts as the definitions window plus a few more:

3.3.7 LaTeX and TeX inspired keybindings
3.3.8 Defining Custom Shortcuts

The Add User-defined Keybindings... menu item in the Keybindings sub-menu of Edit selects a file containing Racket definitions of keybindings. The file must contain a module that uses a special keybindings language, framework/keybinding-lang. To do so, begin your file with this line:

#lang s-exp framework/keybinding-lang

The framework/keybinding-lang languages provides all of the bindings from racket, racket/class, and drracket/tool-lib, except that it adjusts #%module-begin to introduce a keybinding form:

(keybinding string-expr proc-expr)

Declares a keybinding, where string-expr must produce a suitable first argument for map-function in keymap%, and the proc-expr must produce a suitable second argument for add-function in keymap%.

For example, this remaps the key combination “control-a” key to “!”.

#lang s-exp framework/keybinding-lang
(keybinding "c:a" (λ (editor evt) (send editor insert "!")))

Note that DrRacket does not reload this file automatically when you make a change, so you’ll need to restart DrRacket to see changes to the file.