keyFinder.js

A JavaScript tool that helps navigate the Java API documentation.

Developed and Copyright © 2002 by Steve Claflin


News! keyFinder 2.0 Beta version is now available, including:

Currently freeware--licensed freely for use on your own system, but not for distribution to others.

It works with the Sun JDK 1.3 and 1.4.1 docs in Windows IE5+ and Netscape 4.7/4.8 and 6.2, and Mozilla 1.1. I haven't tested other JDK versions, earlier browser versions, other browsers such as Opera, or other platforms.

After installing the script, you can:

Type a class name or the first few letters and the lower left pane (the class hyperlink listing) will scroll to that item and highlight it. (In general, it will jump to whatever class it has identified as first match or, failing a match, the first one after the string you typed. (If you aren't using the form-based approach, there is no text box--you just start pressing keys.)
If you type enough that you have reached the class you want, you can hit enter and the right frame will change to that class page.

If you hit shift-F, the right page will jump to the fields section, shift-C will jump to constructors, shift-M will jump to methods, and shift-I will jump to inner classes.

Pressing the asterisk key will switch to find methods mode, where your typing brings you to the methods list and scrolls to a method whose name matches what you typed. Pressing the asterisk again will return to find classes mode.

Note that the script works on a timer--if you stop typing for a second it will reset. The time delay can be customized by changing the line that reads var keyTimeout = 1000; to use a different number (the number is in milliseconds, so 1000 = 1 second).
Also, sometimes you may have to wait a second or two and try again--there is additional code on a timer that refreshes the script so that the code works after switching class pages.

If you hit an incorrect character, hitting the escape key will clear the finding process so you can start again (or you can wait for the automatic clearing based on keyTimeout).

You may also need to click on a blank spot within a page to initiate keyfinding, especially if you switched to a different application window and then returned. At one time I had the timer reset focus to the page, but that had annoying side effects.
Also note that it currently only works on the "All Classes" listing.

To download: keyFinder.zip (contains the js file and, this page, the optional form page, and several examples of how it can be installed into the index page).

To use it:

  1. Store it in the docs\api directory under your jdk directory

  2. Then edit the index.html file in that directory by adding the following line in the <HEAD> section, under the </TITLE> line:

    <script src="keyFinder.js"></script>

  3. Make the following edits, depending on whether you want a control frame or not:

Then you should be able to pull up the API index page and use the script to navigate through the class pages.

The original version is still available: download keyFinder 1.01.


Give it a try--I'd be interested in any feedback or suggestions you might have.

Queued for development/enhancement:

  1. Ability to work with lists other than All Classes (the reason it doesn't now is that they are formatted differently, with separate categories for interfaces, classes, exceptions, and errors). This would probably require the script to rewrite the class list page to put it into pure alphabetical order.
  2. Expand find methods capability to create an alphabetized list of all available methods, whether from the current class or one of its base classes. This would probably require an additional frame that would be rewritten each time a new class page is loaded.
  3. Facility for adding your own notes to pages--probably not going to happen in the near future.