/* TOPICS: 1. keyDown() function 2. System.out.println output command. 3. boolean function ... return 'true' */ // identifies the key in the keyboard buffer. 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.*; public class bkey10 extends java.applet.Applet { int currkey; public void paint(Graphics g) { g.drawString("Click on the screen to start applet.", 10,10); g.drawString("Type Keyboard Character -- Note its Unicode (Decimal) Value: ",10,30); g.drawString("Unicode/Ascii Value "+currkey+ " = Character " + (char)currkey,10,75); } public boolean keyDown(Event evt, int key) { currkey = key; System.out.println("Unicode/Ascii value: " + key + " Character: " + (char)key); repaint(); return true; } } /* 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 UNICODE/ASCII value of the key. HW: COMPILE THIS. CHANGE keyDown to keyUp. What is the ASCII VALUE OF LF, AND CR? */