Family edition
Keyboard Builder: A Keyboard Never Sends a Letter
Your child gives a small keyboard the arrow keys it does not have, and finds out that a keyboard sends numbers, not letters.
What you need
- A computer or Chromebook with a current browser, and a mouse or trackpad.
- The lesson link: mytekdev.com/try/keyboardbuilder?lesson=a-keyboard-never-sends-a-letter&ref=fam-keyboardbuilder-2. No account, no email and nothing to install.
Before you start: try it once yourself
Open mytekdev.com/try/keyboardbuilder?lesson=a-keyboard-never-sends-a-letter&ref=fam-keyboardbuilder-2. A short guide opens over the app. The keyboard is a 60 percent board, and the customer on the right has no arrow keys and wants them under their fingers. Open the Keymap bench: each cap now shows what its key sends on the layer you are looking at.
- Layer 1. Click Layer 1. Every key fades, because a key with nothing on layer 1 is see-through: it does what layer 0 says.
- Four arrows. Click the I key on the board. The panel reads "On layer 1 it sends whatever layer 0 says." Click Up under Moving. Do the same for J and Left, K and Down, L and Right. The order closes: "With Fn held, four letters are arrows."
- Try it. Press Try your keymap. Click Fn on the board: it stays held, and the line under the board says the computer never hears it. Click I: "Layer 1 answered. The board sent code 52." Click Fn again to let go and click I: "The board sent code 0C. Your computer turned that into "i"."
- Caps Lock. Take the order Nobody needs Caps Lock there. On layer 0, click the Caps Lock key and then Backspace under Editing. The customer says "Now I have no Caps Lock at all." On layer 1, click the same key and then Caps Lock under Editing. The order closes.
The ideas, in plain words
A keyboard does not know the alphabet. When a switch closes, the keyboard's own program, its firmware, looks up that key in a table called the keymap and sends the code it finds. The codes are the same on every USB keyboard: 04 for the A key, 0C for the I key, 52 for the Up arrow. The computer receives the code and looks it up again, in its keyboard layout setting, to choose a character. That is why the same keyboard types different characters when the computer is set to another language.
A layer is a second keymap on the same keys. While Fn is held, the firmware reads layer 1 in place of layer 0. Fn itself sends nothing to the computer: the keyboard handles it alone. Shift, Ctrl and Alt are different again. They are sent, but as eight on-or-off bits beside the key codes, not as keys.
Small keyboards depend on this. The 60 percent board has no arrows, no F keys and no number pad; they live on a second layer. A laptop does the same thing with its Fn key and the top row.
Do it together
- Open mytekdev.com/try/keyboardbuilder?lesson=a-keyboard-never-sends-a-letter&ref=fam-keyboardbuilder-2 together. A short guide opens over the app. Open the Keymap bench and click Layer 1.
You'll know it worked when: Every key fades: nothing is on layer 1 yet.
- Click the I key on the board, then click Up under Moving. Do the same for J (Left), K (Down) and L (Right).
If you get stuck: Check that Layer 1 is still picked. On layer 0 the letters would be lost.
You'll know it worked when: The order closes.
- Press Try your keymap. Click Fn on the board to hold it down, then click I.
You'll know it worked when: The line under the board says layer 1 answered and the board sent code 52.
- Click Fn again to let go, and click I once more.
You'll know it worked when: Now the board sent code 0C, and the computer turned that into an i.
- Ask: the cap still says I. Which part knows it is an arrow?
You'll know it worked when: The keyboard: its keymap says so. The switch only closes, and the computer only gets a code.
Talk about it
Ask these while you work together. A child who has understood it can answer them without help:
- What did the keyboard send when you pressed I? What did the computer do with it?
- The cap says I and the key sends Up. Where is that decided?
- What does the Fn key send to the computer?
- Why did the customer say they had no Caps Lock at all, and how did you give it back?
- If the computer were set to another language, which would change: the code or the character?
For younger and older kids
Younger: For a younger child, stop once the arrows work and let them move a few more keys around.
Older: For an older teen, set the level to High school and read the report the keyboard sends while they hold Shift and a letter.
Keep going
- Take the order One key for a whole line. How many keys does the board press for "Thanks, Sam", and why is it more than the number of characters?
- Under Where the letters go, pick another layout and type your name. The caps did not change. What did?
- Set the level to High school and read the report the keyboard sends on the Type bench. Which part of it changes when you hold Shift?
Bring it into other subjects
- Math: the codes are written in base 16, where 0C means 12 and 52 means 82. What is 2A, the code for Backspace, in base 10?
- World languages: find a picture of a keyboard made for another language. Which keys moved, and which stayed?
- History: the letters on a keyboard are in an order chosen for typewriters in the 1870s. Find out what QWERTY was arranged for, and what is still argued about.
- Design: plan a layer 1 for someone who edits video or draws. Which eight keys would you give them, and where?
For your records
Ready to copy into an hour log, a portfolio or a transcript.
| Lesson | Keyboard Builder: A Keyboard Never Sends a Letter |
|---|---|
| Subjects | Computer science, Technology |
| Time | 45 minutes |
| What we did | Edited a keyboard's keymap in a simulation, added a second layer with arrow keys, and explained that a keyboard sends key codes that the computer turns into characters. |
| Skills practiced | Key codes and keymaps; Layers; Hardware and software working together |
Keyboard Builder: A Keyboard Never Sends a Letter
Activity sheet (optional)
Name: ______________________________ Date: ______________
Open the app: scan the QR code, or go to mytekdev.com/try/keyboardbuilder?lesson=a-keyboard-never-sends-a-letter
Essential question: When you press a key, what does the keyboard really send, and who decides what it means?
Warm-up: You press the A key and an "a" shows up. What do you think the keyboard sent down the cable? ________________________
- Vocabulary. Key code, keymap, layer, firmware, macro: write each in your own words.
- The table. On the Type bench, press each key and copy from the line under the board: the code sent, and what the computer turned it into. The keys: I, then I with Fn held, then the Caps Lock key, then left Shift, then Fn.
1. The cap says I, and with Fn held the key sends Up. Which part made that happen: the switch, the keyboard, or the computer? How do you know?
2. What did the Fn key and the Shift key send that was different from a letter key?
Quick check
Name: ______________________________
1. When you press a key, the keyboard sends (A) the letter on the cap (B) a code for that key (C) a picture of the letter
2. A layer lets a keyboard (A) send two different codes from one key (B) type faster (C) work without a cable
3. The same keyboard types different characters on a computer set to another language. Explain why.
Answers
| Question | Answer | Why |
|---|---|---|
| 1 | B | The keyboard looks the key up in its keymap and sends a code. The computer chooses the character. |
| 2 | A | While Fn is held the keyboard reads a second keymap, so the I key can send the code for Up. |
| 3 | The computer turns codes into characters | The keyboard sends the same codes. The computer looks them up in its own keyboard layout setting, and that setting changed. |
If your state or umbrella school asks, this lesson covers CSTA 2017 3A-CS-02, CSTA 2017 3A-CS-01.