Keyboard shortcut in Mail.app for moving the active email to the top of the inbox

keyboardmail.app

I'm trying out Mail.app on Lion (10.7.3) for the first time and, nice as it is, I'm frustrated that I have to use the mouse to jump to the top of my inbox after using the search function.

To give you an idea of what I'm talking about, here's a quick demo:

  1. option-command-f to search your inbox for something a couple weeks old
  2. tab out of the search field and navigate mail in the mailbox with the arrow keys
  3. option-command-f to go back to the search field and delete your search terms
  4. now tab back into the mailbox view- the old email is selected, and you're miles away from the top of your inbox

Hitting "home" shifts the view to the top of the inbox, but the "cursor" is still on the last active email (i.e. the one that was highlighted in blue), and as soon use you hit the up or down keys, the view will snap/jump back down to show you where the active email is, relative to the top. you're miles away from the top of your inbox again!

command + up arrow, option + up arrow, fn + left arrow, or any combination of arrows, home, and page up keys- none of them will make the topmost email in the mailbox active! It looks like I either have to hit home, then search for a keyword in the topmost email, or use the cursed mouse. Help!

Edit: I couldn't get jtbandes' exact AppleScript to work (I'm an AppleScript oaf; probably my fault), but this worked for me, with the caveat outlined in my comment on his answer:

tell application "System Events"
    tell application "Mail" to activate
    tell application "Mail" to set the selected messages of message viewer 1 to {} -- deselect messages
    key code 115 -- scroll to top
end tell

Best Answer

It's annoying that there isn't a simple keyboard shortcut for this. I suggest providing Mail feedback to Apple if you'd like to see it work properly.

For a workaround, try the following AppleScript:

tell application "Mail"
    set the selected messages of message viewer 1 to {} -- deselect messages
    tell application "System Events"
        key code 115 -- scroll to top
    end tell
end tell

You can make this into a Service and assign a keyboard shortcut to it from the Keyboard section of System Preferences.