Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the best-selling Take Control ebooks.

Hack Microsoft Word's Page Up/Page Down Keys

Microsoft Word has always screwed up the Page Up, Page Down, Home, and End keys on the Mac. I believe - and am willing to quote chapter and verse from the Apple Human Interface Guidelines to support my belief - that they should, respectively, scroll up one screen, scroll down one screen, scroll to the top of the document, and scroll to the bottom of the document. And they should do all this without moving the bloody insertion point!

Before Visual Basic for Applications went away, I wrote some macros that did this and reassigned the key commands. In Word 2008, however, there's no VBA. So I finally figured out four one-line AppleScript scripts that bring back my desired scrolling behavior.

Copy each of these lines to a new document in AppleScript Editor (Snow Leopard) or Script Editor (Leopard) and save them in ~/Documents/Microsoft User Data/Word Script Menu Items, naming them, respectively, "Page Up", "Page Down", "Home", and "End" (the exact names are important for later on). Files in this folder show up in the scripts menu in Word, which is the first step.

tell application "Microsoft Word" to large scroll active pane of active window up 1

tell application "Microsoft Word" to large scroll active pane of active window down 1

tell application "Microsoft Word" to set vertical percent scrolled of active pane of active window to 0

tell application "Microsoft Word" to set vertical percent scrolled of active pane of active window to 100

Then comes the problem of how to assign these scripts to the associated keys. You can't use the Tools > Customize Keyboard command to assign keys to AppleScripts in Word. Microsoft's advice is to put some magic key-equivalent crud at the end of the script's file name (like "\smV" for Shift-Command-V, which I use for Paste Plain). But there's nothing to type for the Page Up, Page Down, Home, and End keys. And, unfortunately, there's no way to add Page Up, Page Down, Home, and End to any key in the Keyboard Shortcuts view of the Keyboard pane of System Preferences.

If you had a macro program like Keyboard Maestro, QuicKeys, or iKey, you could bind the scripts to the appropriate keys within Word. But what if you don't have such a program? Once again, "defaults write" saves the day. In Terminal, first check to see if Word is listed in the results of this command (be sure to copy and paste each of these commands as a single line):

defaults read

If you don't see "" in there (you probably won't), add it with this command:

defaults write -array-add ""

Then, the magic happens with this last command:

defaults write NSUserKeyEquivalents '{"Home" = "\UF729"; "End" = "\UF72B"; "Page Up" = "\UF72C"; "Page Down" = "\UF72D";}'

It's probably best to quit and relaunch Word if it was running, but after all this, you should have Page Up, Page Down, Home, and End keys that scroll the text in view as expected, but without moving the insertion point.

Should you want to reverse the effects of these commands, the easiest way is to (in Snow Leopard) go into the Keyboard Shortcuts view of the Keyboard pane of System Preferences, select Application Shortcuts in the left-hand list, select Microsoft Word in the right-hand list, and click the minus button. (In Leopard, you'd look in the Keyboard view of the Keyboard & Mouse preference pane, and scroll down to the bottom to find Microsoft Word in the list of Application Keyboard Shortcuts.)

[Pete Resnick used to be a Macintosh programmer, and ostensibly knows something about email and the Internet. Now his entire career is reduced to giving presentations and talking to lawyers, hence his constant use of Microsoft Word.]


PDFpen is your Swiss Army knife for PDFs. Slice and dice with tools
for reviewing, editing, signing, redacting, and exporting to Word.
With v.8 use digital signatures, and view file & audio attachments.
Solve your PDF dilemmas, try PDFpen. <>

Comments about Hack Microsoft Word's Page Up/Page Down Keys
(Comments are closed.)

Berend Hasselman  2009-09-09 07:55
Your remarks are very interesting.
I do not use Word but other editors.

I find the behaviour of Home, End, PgUp and PgDn keys in some editors on the mac extremely irritating.
Home should be: goto to start of line. etc.
The standard mac key for that Command+Left arrow is cramped and one key too many.
When one works on different systems, the Mac keys are the odd ones out. Once you get used to certain keys doing a certain thing, muscle memory etc. kicks in. It is impossible to change.

When I do a PgUp or PgDn I absolutely expect the insertion point to remain on screen. If it doesn't I try not use that specific editor.

The interesting thing is that Mac OS X provides a facility to change keybindings with the DefaultKeyBinding.dict.
You can also bind the PgUp and PgDn keys such that the insertion point stays on screen.

It would be most desirable if editors/word processors gave you the choice of behaviour for certain keys.
TextMate lets you work the way you want.

Adam Engst  An apple icon for a TidBITS Staffer 2009-09-28 15:22
There's nothing wrong with editors providing options for people who are used to other systems, but one of the points of the Mac is that applications should follow Apple's Human Interface Guidelines unless they have a darn good reason not to, so users won't be confused by different behavior when moving among different Mac applications.
Tom Standage  2009-09-29 00:44
I have a different problem with Page Up/Page Down and Word. I'm running Office 2008 on a MacBook Air, so I have to use fn+Up/Down in place of Page Up/Page Down. The odd thing is that this works only intermittently. It will scroll for a few pages, then get stuck. The display often gets confused (perhaps the document is scrolling internally but not on the display). This is a really fundamental bug for such a widely used program. But because nobody else seems to be complaining about it, I wonder if it's specific to the Air.
Adam Engst  An apple icon for a TidBITS Staffer 2009-09-29 06:58
Don't get me started about the fn key.... :-)

I wonder what would happen if you used something like Keyboard Maestro to remap the Page Up/Page Down keys to some other combination that doesn't require the fn key. Perhaps you have an intermittent connection with fn, but it manifests itself only when held down. I suppose you could also test this by using fn-Page Up/Down in another program and seeing if the keystrokes are lost there too.