import matplotlib.pyplot as plt
# Basic ASCII values for US QWERTY keys (simplified)
ascii_map = {
"`": "96/0x60", "1": "49/0x31", "2": "50/0x32", "3": "51/0x33",
"4": "52/0x34", "5": "53/0x35", "6": "54/0x36", "7": "55/0x37",
"8": "56/0x38", "9": "57/0x39", "0": "48/0x30", "-": "45/0x2D",
"=": "61/0x3D", "Q": "81/0x51", "W": "87/0x57", "E": "69/0x45",
"R": "82/0x52", "T": "84/0x54", "Y": "89/0x59", "U": "85/0x55",
"I": "73/0x49", "O": "79/0x4F", "P": "80/0x50", "[": "91/0x5B",
"]": "93/0x5D", "\\": "92/0x5C", "A": "65/0x41", "S": "83/0x53",
"D": "68/0x44", "F": "70/0x46", "G": "71/0x47", "H": "72/0x48",
"J": "74/0x4A", "K": "75/0x4B", "L": "76/0x4C", ";": "59/0x3B",
"'": "39/0x27", "Z": "90/0x5A", "X": "88/0x58", "C": "67/0x43",
"V": "86/0x56", "B": "66/0x42", "N": "78/0x4E", "M": "77/0x4D",
",": "44/0x2C", ".": "46/0x2E", "/": "47/0x2F", " ": "32/0x20"
}
# Keyboard layout
keyboard_rows = [
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace"],
["Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\"],
["Caps", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "Enter"],
["Shift", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "Shift"],
["Ctrl", "Win", "Alt", "Space", "Alt", "Fn", "Menu", "Ctrl"]
]
# Key sizes (approximate)
key_sizes = {
"Backspace": 2, "Tab": 1.5, "Caps": 1.75, "Enter": 2.25,
"Shift": 2.25, "Space": 6, "Ctrl": 1.25, "Alt": 1.25,
"Fn": 1.25, "Menu": 1.25, "Win": 1.25
}
fig, ax = plt.subplots(figsize=(20, 8))
y = 0
for row in keyboard_rows:
x = 0
for key in row:
w = key_sizes.get(key, 1)
ax.add_patch(plt.Rectangle((x, -y), w, -1, facecolor="#E0E0E0", edgecolor="black"))
# Key symbol
ax.text(x + w/2, -y - 0.35, key, ha="center", va="center", fontsize=10, fontweight="bold")
# ASCII value if applicable
if key in ascii_map:
ax.text(x + w/2, -y - 0.7, ascii_map[key], ha="center", va="center", fontsize=7, color="blue")
x += w
y += 1
ax.set_xlim(0, 15)
ax.set_ylim(-6, 1)
ax.axis("off")
plt.title("ASCII Keyboard Layout with ASCII Codes", fontsize=18, fontweight="bold")
plt.show()

Here’s the ASCII Keyboard Layout with ASCII Codes — each printable character key now shows its decimal and hex ASCII values underneath (e.g., A → 65/0x41, space → 32/0x20).
Would you like me to add the control characters (ASCII 0–31, DEL 127) in a separate reference table beside this keyboard, so you get the full ASCII spectrum in one place?
import matplotlib.pyplot as plt
# ASCII Control Characters (0-31, 127)
control_ascii = [
(0, "NUL", "Null"), (1, "SOH", "Start of Header"), (2, "STX", "Start of Text"),
(3, "ETX", "End of Text"), (4, "EOT", "End of Transmission"), (5, "ENQ", "Enquiry"),
(6, "ACK", "Acknowledge"), (7, "BEL", "Bell"), (8, "BS", "Backspace"),
(9, "TAB", "Horizontal Tab"), (10, "LF", "Line Feed"), (11, "VT", "Vertical Tab"),
(12, "FF", "Form Feed"), (13, "CR", "Carriage Return"), (14, "SO", "Shift Out"),
(15, "SI", "Shift In"), (16, "DLE", "Data Link Escape"), (17, "DC1", "Device Control 1"),
(18, "DC2", "Device Control 2"), (19, "DC3", "Device Control 3"), (20, "DC4", "Device Control 4"),
(21, "NAK", "Negative Acknowledge"), (22, "SYN", "Synchronous Idle"), (23, "ETB", "End of Transmission Block"),
(24, "CAN", "Cancel"), (25, "EM", "End of Medium"), (26, "SUB", "Substitute"),
(27, "ESC", "Escape"), (28, "FS", "File Separator"), (29, "GS", "Group Separator"),
(30, "RS", "Record Separator"), (31, "US", "Unit Separator"), (127, "DEL", "Delete")
]
# Grid layout
cols = 8
rows = (len(control_ascii) // cols) + 1
fig, ax = plt.subplots(figsize=(18, 8))
for idx, (code, abbr, desc) in enumerate(control_ascii):
row = idx // cols
col = idx % cols
ax.add_patch(plt.Rectangle((col, -row), 1, -1, facecolor="#D3D3D3", alpha=0.7, edgecolor="black"))
ax.text(col + 0.5, -row - 0.35, f"{code}", ha="center", va="center", fontsize=10, fontweight="bold")
ax.text(col + 0.5, -row - 0.65, abbr, ha="center", va="center", fontsize=8, fontweight="bold", color="blue")
ax.text(col + 0.5, -row - 0.9, desc, ha="center", va="center", fontsize=6)
ax.set_xlim(0, cols)
ax.set_ylim(-rows, 1)
ax.axis("off")
plt.title("ASCII Control Characters (0–31, 127)", fontsize=18, fontweight="bold")
plt.show()

Here’s the ASCII Control Characters Table — showing codes 0–31 plus 127 (Delete), each with its decimal value, abbreviation, and description.
Would you like me to now combine this control character table with the keyboard layout into a single full ASCII map (0–127) so you can see printable and non-printable characters together?