Although I personally use NetNewsWire for my RSS reading, Safari’s built-in RSS reader works well and is the tool of choice for many people. One thing that many people find annoying, however, has to do with where Safari leaves the cursor when it’s done loading an RSS page: in the Search box on the right side of the page.
The problem with this is that all keystrokes are captured by the Search box, and many people use the Space Bar (and Shift Space Bar) for scrolling down (and up) a page at a time in Safari. If you’re one of those people, today’s tip will show you how to have the best of both worlds: the Space Bar will work for page scrolling, while the cursor will remain in the Search box, ready to receive any search text you wish to type.
I’m aware that there are many ways to make Safari scroll using the keyboard—Page Down and Page Up come to mind as the obvious choices. These keys, along with the Fn-based alternatives on laptops—work just fine with the Search field active. However, there are people who find the Space Bar to be the most convenient method of scrolling pages, given that a typical user’s thumb is nearly always positioned directly over that key. If you don’t mind using other keys, then this hint is not for you!
Note: This tip requires modifying a system-wide piece of code. The changes you make will therefore be seen by any other program that calls the same system-level code—so this tip may affect more than just Safari. Also, because the file to be modified is in the System folder, it’s quite possible that a future system update may overwrite your changes—don’t be surprised if this tip stops working at some point in the future.
The first step is to navigate to the folder containing the code we need to modify. In the Finder, open /Sytem -> Library -> PrivateFrameworks -> SyndicationUI.framework -> Resources. The file we’ll be editing is Article.js, and the first thing to do is make a backup of this file—just drag it to another folder, such as your Documents folder, and the Finder will automatically create a copy, leaving the original alone. (Since you’re not editing a file directly within Safari, it doesn’t matter if Safari is running or not.)
To edit this file, since it’s system-owned, you’ll need to either use Terminal with sudo
, or a text editor such as
Smultron or
TextWrangler 2 (both free) that can edit and save system-owned files. Open the file in your editor of choice, and then use the editor’s search function to search for function handleScrollKeys . You should jump down to a section of the file around line 983 that starts like this:
function handleScrollKeys( event ) { if ( scroller == undefined ) scroller = document....Down toward the bottom of this function, you’ll see these two lines:
default: return;Just above the
default
line, add this code: case "U+000020": if (document.getElementById('searchfield').value.length != 0) return; if (event.shiftKey) scroller.scrollByPages(-1); else scroller.scrollByPages(1); break;When you’re done, the result should look like this:
... scroller.scrollTop = scroller.scrollHeight; break; case "U+000020": (document.getElementById('searchfield').value.length != 0) return; if (event.shiftKey) scroller.scrollByPages(-1); else scroller.scrollByPages(1); break; default: return; ...
Now save the changes you made; if you’re using TextWrangler or Smultron (or another GUI editor), you’ll be asked to authenticate as an administrative user before your changes can be saved. Quit the editor, return to Safari, and load an RSS feed. Press the Space bar, and notice that page scrolling now works as expected. Also notice that if you type other characters, they show up as expected in the Search box, and Safari begins to narrow the results as you type.
I tested this in both Safari 2 and Safari 3 Public Beta, and it worked just fine in both. If you ever want to undo your changes, either re-edit the file and remove the added code, or just copy your backup Article.js file over the modified version. And as noted earlier, don’t be surprised if your handiwork vanishes after a future system update.