/* TOPICS: 1. keyDown() function 2. System.out.println output command. 3. boolean function ... return 'true' */ // Respect dos95 long names. // Watch case. // Identifies the key in the keyboard buffer. // put the following statements in order and compile program. // STEP 1.0 -- insert all library statements. // STEP 2.0 -- insert: "bkey7 is a class object that inherits qualities from the // "Applet" superclass. // STEP 3.0 -- define 'currkey' as an integer. // STEP 4.0 -- start a method (routine) that enables graphics. // -- draw 'Applet started" message -- col 10, row 10. // -- draw a catenated string containing UNICODE and Char values. // STEP 5.0 -- code method that listens for 'events'. with 'key' as the // name of the variable containing the integer value of the // keystroke. // Store the value of 'key' into 'currkey' // Print out a line to the DOS Window. // Repaint the screen to reflect new keystroke. // A value of 'true' is generated. // /* YOU MAY USE THE FOLLOWING STATEMENTS TO WRITE YOUR APPLET. public void paint(Graphics g) { g.drawString("applet started",10,10); return true; } } import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.Graphics; import java.awt.Font; import java.awt.Color; import java.lang.Math; import java.util.Date; import java.util.Random; import java.util.*; System.out.println("Character: " + (char)key + " UNICODE Value: " + key); repaint(); public boolean keyDown(int key) { currkey = key; public class bkey7 extends java.applet.Applet { int currkey; g.drawString("Character = " + (char)currkey + " UNICODE Value = " + currkey,10,75); } // --- END OF JAVA STATEMENTS */ /* PROGRAM DESCRIPTION Pressing a key -- a number, letter, function or special keys -- generates a 'keyboard event' that is passed into "KeyDown()" as an argument. "char(key)" gives the ASCII value of the key. HW: COMPILE THIS. What is the ASCII VALUE OF LF, AND CR? COMPLETE THE CHART (757/790 UNICODE CHART -- POSTED) DETERMINE VALUE OF F1 .. F12 FUNCTION KEYS */