RichEdit Hot Keys

This post summarizes the hot keys built into RichEdit. Previous posts have described various math hot keys like Alt+=. But AFAIK no one has published a summary of all the RichEdit hot keys. Note that RichEdit clients, e.g., OneNote, often handle all hot key combinations with RichEdit never seeing the corresponding keyboard messages. Since the client is the one that receives the keyboard input, it can do whatever it wants to with that input. This flexibility is valuable particularly with regard to localizing the hot keys. RichEdit is “globalized”, but not localized. A number of the hot keys described in this post are English-centric and should be localized by the client. Other hot keys are globalized by nature and can be used as is.

A very interesting pair of globalized hot keys is that for setting the BiDi directionality of a paragraph. These hot keys depend on knowing the difference between right and left. The WM_KEYDOWN message passes information in the lparam that’s needed to figure out right Shift from left Shift. Specifically, byte 2 of lparam gives the key’s scan code and the value 0x36 is the scan code for the right-shift key ever since IBM shipped the first PC. This information lets RichEdit handle the Ctrl+RightShift hot key to switch the BiDi paragraph directionality to RTL (right to left). Similarly, Ctrl+LeftShift switches to LTR. RichEdit tracks which Alt, Shift, and Ctrl keys are depressed at any given time. This enables it to differentiate between left Alt for menus and right Alt (AltGr) for keyboard commands. But the most important use is for the Ctrl+RightShift and Ctrl+LeftShift hot keys. Lots of other Word hot keys are implemented.

RichEdit supports Word’s standard subscript and superscript hot keys: Ctrl+= and Ctrl+Shift+=, respectively. These hot keys toggle their respective states. For example, if you type some text, Ctrl+=, and some more text, the latter will be subscripted up until you type Ctrl+= again to go back on line. If you type one of these hot keys while some text is selected, that text’s script character will be toggled accordingly. In the linear format, subscripts and superscripts are usually entered with the _ and ^ operators as in [La]TeX or via the ribbon. But the standard hot keys can be handy too provided the scripts are not nested.

Navigation Keys

Arrow, PgUp/PgDn, and Home/End key behavior is summarized in the following table for ordinary text (behavior in math zones may be different). A depressed state of the Shift, Ctrl, and Alt keys is given by ✓; else the key isn’t depressed.

 Key

 Shift  

 Ctrl 

 Alt 

 Action

 

 

 

Move left char

 

 

Move left word

 

 

Select left char

 

Select left word

 

 

 

Move up line

 

 

Move to start of paragraph

 

 

Select up line

 

Select to start of paragraph

 

 

 

Move right char

 

 

Move right word

 

 

Select right char

 

Select right word

 

 

 

Move down line

 

 

Move to end of paragraph

 

 

Select down line

 

Select to end of paragraph

PgUp

 

 

 

Move up one screen

PgUp

 

 

Move to start of screen

PgUp

 

 

Select up one screen

PgUp

 

Select to start of screen

PgDn

 

 

 

Move down one screen

PgDn

 

 

Move to end of screen

PgDn

 

 

Select down one screen

PgDn

 

Select to end of screen

Home

 

 

 

Move to start of line

Home

 

 

Move to start of story

Home

 

 

Select to start of line

Home

 

Select to start of story

End

 

 

 

Move to end of line

End

 

 

Move to end of story

End

 

 

Select to end of line

End

 

Select to end of story

 

Arrow-key behavior in vertical text differs to correspond to the different direction. For example, ↓ goes to the next character instead of going to the next line. See Math Selection for a discussion of how the navigation keys work in a math zone. An important point is that if you select a math structure character (start of object, end of object, or end of argument), the whole object is automatically selected.

Tab key

Typically typing the Tab key inserts a Tab character (U+0009). But depending on context, the Tab key may turn into a navigation key. For example, in a table cell, the Tab key goes to the next cell and Shift+Tab goes to the previous cell (if any). If the selection is in the last cell of a table, the Tab key inserts a new row after the last row with the insertion point in the first cell of the new row.

In math zones, the Tab key goes to the next argument of the current math function and the Shift+Tab key goes to the previous argument. This behavior was originally scheduled for Word as well, but got postponed.

In windowed dialog controls, Tab characters are ignored. This allows dialogs to use the Tab character to move from control to control.

Enter key

The Enter key usually inserts an end-of-paragraph character (U+000D—carriage return) and the Shift+Enter key inserts an end-of-line character (U+000B—VT). See Paragraphs and Paragraph Formatting for a discussion of the differences between these kinds of insertions. At the end of a table row, the Enter key inserts a new row after the current row. Inside a math object argument, an Enter key inserts an equation array. This is handy for the lower limit of n-ary objects like summations, which may have more than one subscript range. In a display math zone, Shift+Enter starts a new equation (see The Math Paragraph for details).

Delete key

If the current selection is nondegenerate (selects one or more characters), the Delete key deletes the selected characters. If the current selection is degenerate, i.e., an insertion point (IP), the Delete key usually deletes the character immediately following the IP. If the character is followed by one or more combining marks, the Delete key deletes the whole combining-mark sequence. Similarly if the character is followed by a variation selector, the Delete key deletes the whole variation-selector sequence. If the Ctrl key is pressed for an insertion point, the Delete key deletes the word following the IP. See Math Selection for a discussion of how the Delete and Backspace keys work in math zones. In particular, the math object is selected if you type Delete at the start of the object or Backspace at the end the object. A second Delete or Backspace then deletes the object. This behavior exists so that you don’t delete things by mistake. If you do so anyway, you can always undo your deletion by typing Ctrl+Z.

Backspace key

The Backspace key is similar to the Delete key, but has some differences in addition to operating on the character preceding the insert point. If the current selection is nondegenerate, the Backspace key acts the same as the Delete key and deletes the selected characters. If the current selection is degenerate, i.e., an insertion point, the Backspace key usually deletes the character immediately preceding the insertion point. If that character is a combining mark, the Backspace key deletes that combining mark alone. This differs from the Delete key at the start of a combining-mark sequence, which deletes the whole combining-mark sequence. If the preceding character is a variation selector, the Backspace key deletes the whole variation-selector sequence. If the Ctrl key is pressed for an insertion point, the Backspace key deletes the word preceding the IP. See Math Selection for a discussion of how the Backspace key works in math zones. In particular, the math object is selected if you type Backspace at the end the object. A second Backspace then deletes the object. Alt+Backspace is an alias for Ctrl+Z (undo).

Hot Keys like Ctrl+C

The following table lists additional hot keys handled by RichEdit

Key

Shift

Ctrl

Alt

Action

=

 

 

Toggle subscript mode

=

 

Toggle superscript mode

=

 

 

Insert math zone

=

 

Build down selected math text

=

Build up selected math text

-

 

 

Insert soft hyphen (U+00AD)

-

 

Insert nonbreaking hyphen (U+20✓✓)

,

 

 

Cedilla accent dead key (English only)

 

 

Acute accent dead key (English only)

 

Smart quotes (English only)

~

 

Tilde accent dead key (English only)

;

 

 

Dieresis accent dead key (English only)

`

 

 

Grave accent dead key (English only)

 

Make font bigger

 

Make font smaller

!

Insert ¡ (English only)

?

Insert ¿ (English only)

1

 

 

Single spacing

2

 

 

Double spacing

5

 

 

1.5 spacing

6

 

 

Caret accent dead key (English only)

A

 

 

Select All

A

 

Toggle all caps

B

 

 

Toggle bold

C