For a teacher with a class? The classroom edition has the full plan, slides and standards.

Homeschooling PDF

Family edition

Keyboard Builder: The Key Nobody Pressed

Ages 12-16 ยท about 45 minutes, in one sitting

Your child finds out how a keyboard knows which keys are down, and catches it reporting a key nobody pressed.

What you need

Before you start: try it once yourself

Open mytekdev.com/try/keyboardbuilder?lesson=the-key-nobody-pressed&ref=fam-keyboardbuilder-1. A short guide opens over the app. The keyboard is a 60 percent board, 61 keys, and an order from a customer is on the right. Open the Matrix bench: the caps turn see-through and the gold lines under them are the row and column wires.

  1. The ghost. Click Q, W and A on the board. Each click holds a key down. S lights up pink, and the line under the board reads "The board sees 4 keys. You are holding 3. The pink one is a ghost."
  2. The fix. Under Diodes, click On. The line reads "You are holding 3 keys. The board sees 3." and the order closes with "Three keys held, three keys read."
  3. The cheaper fix. Take the order It says anti-ghosting on the box. The three keys are still held. Click Off under Diodes, then Block the doubt. The line reads "You are holding 3 keys. The board reports 2. It dropped A because it could not be sure." Three answers appear on the right; the one that closes the order is "No made-up key, but a real key can go missing".
  4. Other threes. Set the controller back to Report everything, and press Let go of every key before each test: a click on a held key lets it go. A, S and W give a ghost at Q. J, K and I give a ghost at O. Q, W and E, all in one row, give no ghost.
The moment that lands is the second fix. Children expect "anti-ghosting" to mean every key works, and the board throws away a key they are holding.

The ideas, in plain words

A wire for every key would take 61 pins on the controller, and the one in the app has 26. So the keys are wired as a grid. Each switch joins one row wire to one column wire. The controller powers one column at a time and reads the rows, about 1,800 times a second in the app, and works out which crossings are closed.

The trouble comes when three held keys sit on three corners of a rectangle: two rows and two columns. Current can run from the powered column through one switch, along a row, backward through a second switch, and through the third to the row of the fourth corner. The controller reads that row as joined to that column, and reports a key nobody pressed. A diode beside each switch lets current go one way only, which breaks the backward step. The other fix costs nothing: when a new key could be a ghost, the controller ignores it until another key is let go. Engineers call that blocking or jamming.

The keyboard in the app is a model. Its grid is the textbook one, with every key on its own row and column crossing; a real board often folds the grid to save pins. A real keyboard you can buy today almost never shows a ghost key: it either has a diode at every switch or it drops the key it cannot be sure of. On the Matrix bench, the panel named The keyboard in front of you counts the keys a child's real keyboard is reporting: on many laptops the count stops at 2 for some sets of three keys.

Do it together

  1. Open mytekdev.com/try/keyboardbuilder?lesson=the-key-nobody-pressed&ref=fam-keyboardbuilder-1 together. A short guide opens over the app. Open the Matrix bench and count the gold wires: 5 rows and 14 columns.

    You'll know it worked when: That is 19 wires for 61 keys.

  2. Click Q, W and A on the drawn board so all three stay down.

    If you get stuck: Click the keys on the screen. Your own keyboard will not show this.

    You'll know it worked when: S lights up pink. The line under the board says it sees 4 keys and you are holding 3.

  3. Under Diodes, click On.

    You'll know it worked when: Three keys held, three keys lit, and the order closes.

  4. Take the order It says anti-ghosting on the box. With the three keys still held, click Off under Diodes, then Block the doubt.

    If you get stuck: If the keys were let go, click Q, W and A again, in that order.

    You'll know it worked when: The board reports 2 keys. It dropped A because it could not be sure.

  5. Ask: which fix would you pay for, and why?

    You'll know it worked when: Diodes read every key and need one more part for each key. Blocking is free and loses a real key.

Talk about it

Ask these while you work together. A child who has understood it can answer them without help:

The second question is the real test: a child who says the ghost is the fourth corner of the square has the idea.

For younger and older kids

Younger: For a younger child, stop after the diodes and ask them to find another three keys that make a ghost.

Older: For an older teen, set the level to High school and ask them to draw the path the current takes around three closed switches to the fourth.

Keep going

Bring it into other subjects

For your records

Ready to copy into an hour log, a portfolio or a transcript.

LessonKeyboard Builder: The Key Nobody Pressed
SubjectsComputer science, Technology
Time45 minutes
What we didUsed a keyboard simulation to see how a key matrix is scanned, made a ghost key appear, fixed it with diodes, and compared that fix with blocking.
Skills practicedHow a keyboard matrix works; Testing a fix; Comparing two designs

Keyboard Builder: The Key Nobody Pressed

Activity sheet (optional)

Name: ______________________________ Date: ______________

Open the app: scan the QR code, or go to mytekdev.com/try/keyboardbuilder?lesson=the-key-nobody-pressed

Essential question: How does a keyboard with 61 keys tell which ones are down using only 19 wires?

Warm-up: A keyboard has 61 keys. How many wires do you think it needs? ________

  1. Vocabulary. Matrix, controller, scan, ghost key, diode: write each in your own words.
  2. Count. Rows ________ Columns ________ Pins ________ Pins with one wire per key ________
  3. The test table. For each test write the three keys you held, the diodes (on or off), what the controller does, and what the board saw. Start with Q, W, A three ways: no diodes, diodes on, and blocking the doubt. Then A, S, W and Q, W, E with no diodes, and one set of your own.

1. Why did S light up when you held Q, W and A? Use the words row and column.

2. Diodes or blocking: which fix would you choose for a keyboard used for games, and what does it cost?

Quick check

Name: ______________________________

1. A keyboard matrix finds a pressed key by (A) a separate wire for every key (B) checking which row and column are joined (C) reading the letter printed on the cap

2. With no diodes, Q, W and A held made S appear because (A) S is a worn-out key (B) the four keys share two rows and two columns (C) the board scans too slowly

3. A box says "anti-ghosting". Name one thing that keyboard might do when three keys are held.

Answers

QuestionAnswerWhy
1BEach switch joins one row to one column, and the controller scans for the crossings that are closed.
2BThree closed switches on three corners of a rectangle give the current a way around to the fourth corner.
3Drop one of the keysIt can ignore a key it cannot be sure of, so no ghost shows but a real key goes missing. "Read all three, because it has diodes" is also right.

If your state or umbrella school asks, this lesson covers CSTA 2017 2-CS-03, CSTA 2017 3A-CS-01, CSTA 2026 HS-SYS-HW-30.