Central Connecticut State University, Spring 2000

Keyboard Class Instructions -- CCSU Version

Introduction. The Keyboard class is taken from John Lewis's website at http://hawk.csc.villanova.edu/jss/keyboard.html. (John Lewis is the co-author of the Lewis and Loftus text, Java Software Solutions, which we use for CS 151.) The basic purpose of the Keyboard class is to simplify keyboard input in screen based Java programs. You might compare the Echo.java program in listing 2.10 on page 86 of the text with the corresponding program in Kjell's Web notes to see what a simplification the Keyboard class is.

Usage. The package statement on the first line of John Lewis's original class has been removed to make it easier to use at Central Connecticut State. If you wish, you can use Lewis's ORIGINAL class WHILE AT HOME and follow his instructions, but AT CCCSU and WHEN HANDING IN PROJECTS you should do the following:

  1. COPY Keyboard.java -- the CCSU version -- to the directory where your Java source code resides. For instance, if you are handing in project 1 on a floppy disk and all the .java files are going to reside in the root directory of the A: drive, be sure you put a copy of Keyboard.java there too.
  2. Compile everything on the disk to get the .class files.
  3. Run the main programs on the disk to check that the versions you put on the floppy disk run correctly.

This is NOT the way you are supposed to do things from a software engineering point of view, but it would simply not be practical to ask InfoSys to install the original package version of the Keyboard.class in the correct location on every machine on campus.

Downloading. To download Keyboard.java -- the CCSU version, do the following:

  1. Click here to bring up the text of Keyboard.java in your Web browser.
  2. On the main menu bar of your web browser, click Edit --> Select All to copy the text of Keyboard.java to the clipboard.
  3. Start up your favorite editor (maybe Notepad on an NT or Windows machine, or BBEdit on a Mac).
  4. On the main menu bar of the editor you just started, click Edit --> Copy to copy the text of Keyboard.java from the clipboard to your editor window.
  5. Save the editor file as Keyboard.java. (No period at the end.)

This page is best viewed with Netscape Navigator

Return to the Java Resources Page.