iOS keyboard (iPad): the iPad mini's own rows on every docked iPad, the Hex key in Apple's dictation slot (#2332)

Phase 2 of the iPad keyboard. Docked, Hex had the iPhone's rows at Apple's iPad sizes; now it
has Apple's iPad mini rows (iPadOS 27.2 simulator, black box), used on the 11- and 13-inch too
until their own rows (tab, caps lock, the 13-inch's number row) exist:
- delete ends row 1, return row 2, a shift key on both ends of row 3, and after the letters
  Apple's two-symbol keys: , ! and . ? (AZERTY , ? . ! and ' :), drawn with the shifted symbol
  over the typed one and typed with shift (new KeyboardKey.shifted);
- bottom row: globe, 123, the Hex key where Apple's dictation key is, space, emoji (123 with
  Emoji off) where Apple's second 123 is, hide keyboard. On a docked iPad the Hex key is always
  there, whatever Settings › Hex key says; the strip is all suggestions (the layout's
  hexPlacement is .leftOfSpace there);
- widths as Apple's: letters as wide as the longest row allows with its delete/return at
  least 1.236/1.24 letters, row 2 set in 0.4 of a pitch (0.2 when as long as row 1, AZERTY),
  left shift a letter (1.061 on AZERTY), the row-ending keys take the rest, the bottom row the
  same in every language;
- 123 and #+= pages as Apple's mini (digits and delete; @ # $ & * ( ) ' " / € £ ¥ _ ^ [ ] { }
  and return; a page key either side of % - + = / ; : , . / § | ~ … \ < > ! ?), ABC in place
  of Apple's undo and second ABC;
- German on a docked iPad is plain QWERTZ (Apple's iPad German has no ü ö ä keys), holding
  ü ö ä on u o a as Hex's plain QWERTZ already does.
New file KeyboardPadRows.swift (KeyboardLayout.buildPadKeys); the phone builder is untouched.
Floating iPads keep Apple's floating (iPhone-like) layout.

Decoder: unchanged code. It still gets only letter keys' frames and the letter pitch
(TypingDecoder.Geometry, AdaptiveTouchGeometry, SwipeDecoder filter on isLetter); the
two-symbol keys are not letters. What changes for it on a docked iPad: the letter frames
(new positions and widths, KeyboardLayout.letterWidth returns the iPad letter width), and
German's letter set, which loses ü ö ä as keys (as Hex's existing plain QWERTZ).

Settings › Keyboard › Number row (#2327, iPhone only) does nothing on an iPad: checked in
the layout tests and on the iPad mini and floating simulators with it on.

Also: FullKeyboardEngineTests.testFrequentlyUsedFillsEightColumns pinned upright
(orientationOverride): on an iPad simulator left in landscape the grid filled with four rows
and was read with three (reproduced on origin/dev, passes now).

Verified (iPadOS 27.2 simulators): Hex against Apple's mini in English, German and French,
upright and turned, every key within a point (overlays in
~/Downloads/hex-ipad-keyboard-2026-11-22/phase2/); real touches on mini, 11- and 13-inch:
teh, -> the, shift , -> !, shift . -> ?, swipe typing, return, delete, the 123 and #+= pages,
the Hex key recording, hide; QWERTZ and AZERTY typing, French ' and shift ' -> : as Apple's,
German holds offering ü and ä; iPhone 17 Pro pixels as origin/dev (light: either build shows
one of two states 53 pixels apart at the glass's left edge, origin/dev included); full suite
747 tests (3 skipped, 0 failures) on an iPhone 17 Pro and an iPad Pro 13-inch simulator.
This commit is contained in:
Ryan Vogel
2026-11-22 01:47:25 -05:00
committed by GitHub
parent ff57e6d39a
commit 048a47518b
7 changed files with 304 additions and 10 deletions
@@ -1068,6 +1068,9 @@ final class FullKeyboardEngineTests: XCTestCase {
for _ in 0..<3 { usage.record("🦦") }
usage.record("🍕")
view.makeEmojiUsage = { usage }
// Upright whatever the simulator: turned (an iPad simulator left in landscape) the grid
// has three rows, and the panel filled under one orientation was read under the other.
view.orientationOverride = .portrait
view.frame = CGRect(x: 0, y: 0, width: 402, height: 306)
view.layoutIfNeeded()
view.debugOpenEmoji()
+82 -2
View File
@@ -1667,7 +1667,7 @@ final class KeyboardLayoutTests: XCTestCase {
let q = layout.key(.character("q"))!.frame, w = layout.key(.character("w"))!.frame
XCTAssertEqual(q.minX, side, accuracy: 0.001, label)
XCTAssertEqual(w.minX - q.maxX, gap, accuracy: 0.001, label)
XCTAssertEqual(layout.key(.character("p"))!.frame.maxX, screen.width - side, accuracy: 0.001, label)
XCTAssertEqual(layout.key(.delete)!.frame.maxX, screen.width - side, accuracy: 0.001, label)
// The strip, Apple's 44 pt bar, under 44 pt kept clear for iPadOS's shortcut bar.
XCTAssertEqual(layout.metrics.stripTop, 44, label)
XCTAssertEqual(layout.stripFrame.height, 44, label)
@@ -1680,6 +1680,86 @@ final class KeyboardLayoutTests: XCTestCase {
/// Apple's floating keyboard (the same 320 pt on every iPad): 26 pt keycaps on a 54.3 pt
/// pitch, 4 pt in, shift and delete 35.5 pt, 123 and return 73.5 pt with space 153 pt
/// between, all in 271 pt under its 44 pt bar; Hex's strip takes the bar's place.
/// The docked iPad's own rows against Apple's iPad mini keyboard (iPadOS 27.2 simulator,
/// screenshots): every key's width and where each row starts, English, German and French,
/// upright and turned. Hex's bottom row is Apple's with the Hex key where its dictation key
/// is and emoji (when on) where its second 123 is.
func testPadMiniRowsMatchApples() {
struct Apple { let language: KeyboardLanguage; let orientation: KeyboardOrientation; let width: CGFloat
let letter: CGFloat; let delete: CGFloat; let rowTwoX: CGFloat; let returnW: CGFloat; let shift: CGFloat; let rightShift: CGFloat; let bottom: [CGFloat] }
let apple = [
Apple(language: .english, orientation: .portrait, width: 744, letter: 54.5, delete: 67.5, rowTwoX: 32.5, returnW: 107.5, shift: 54.5, rightShift: 67.5, bottom: [57, 57, 57, 318, 91.5, 91.5]),
Apple(language: .german, orientation: .portrait, width: 744, letter: 54.5, delete: 67.5, rowTwoX: 32.5, returnW: 107.5, shift: 54.5, rightShift: 67.5, bottom: [57, 57, 57, 318, 91.5, 91.5]),
Apple(language: .french, orientation: .portrait, width: 744, letter: 53.25, delete: 79.5, rowTwoX: 19, returnW: 66.5, shift: 56.5, rightShift: 76, bottom: [57, 57, 57, 318, 91.5, 91.5]),
Apple(language: .english, orientation: .landscape, width: 1133, letter: 87.1, delete: 107.5, rowTwoX: 47.5, returnW: 168, shift: 87.1, rightShift: 107.5, bottom: [89, 89, 88.5, 502, 140, 140.5]),
Apple(language: .german, orientation: .landscape, width: 1133, letter: 87.1, delete: 107.5, rowTwoX: 47.5, returnW: 168, shift: 87.1, rightShift: 107.5, bottom: [89, 89, 88.5, 502, 140, 140.5]),
Apple(language: .french, orientation: .landscape, width: 1133, letter: 85.4, delete: 125, rowTwoX: 27, returnW: 105.5, shift: 90.5, rightShift: 120, bottom: [89, 89, 88.5, 502, 140, 140.5]),
]
for a in apple {
let layout = KeyboardLayout(width: a.width, orientation: a.orientation, showsGlobe: true, showsEmoji: true, language: a.language, pad: .docked(.mini))
let label = "\(a.language) \(a.orientation)"
let rows = (0..<4).map { r in layout.keys.filter { $0.row == r }.sorted { $0.frame.minX < $1.frame.minX } }
XCTAssertEqual(layout.letterWidth, a.letter, accuracy: 0.5, label)
XCTAssertEqual(rows[0].last?.kind, .delete, label)
XCTAssertEqual(rows[0].last!.frame.width, a.delete, accuracy: 1, label)
XCTAssertEqual(rows[1].first!.frame.minX, a.rowTwoX, accuracy: 0.75, label)
XCTAssertEqual(rows[1].last?.kind, .returnKey, label)
XCTAssertEqual(rows[1].last!.frame.width, a.returnW, accuracy: 1, label)
XCTAssertEqual(rows[2].first?.kind, .shift, label)
XCTAssertEqual(rows[2].last?.kind, .shift, label)
XCTAssertEqual(rows[2].first!.frame.width, a.shift, accuracy: 0.75, label)
XCTAssertEqual(rows[2].last!.frame.width, a.rightShift, accuracy: 1, label)
XCTAssertEqual(rows[2].count, 11, label)
XCTAssertEqual(rows[3].map(\.kind), [.globe, .layerSwitch(.numbers), .hex, .space, .emoji, .dismiss], label)
for (key, width) in zip(rows[3], a.bottom) { XCTAssertEqual(key.frame.width, width, accuracy: 1, "\(label) \(key.label)") }
XCTAssertNil(layout.key(.hex).flatMap { $0.row < 0 ? $0 : nil }, "no Hex key in the strip: \(label)")
XCTAssertEqual(layout.stripFrame.width, layout.stripBarFrame.width, label)
}
// German on an iPad is QWERTZ without ü ö ä, held on u o a; French ends row 3 in , . and '.
let german = KeyboardLayout(width: 744, language: .german, pad: .docked(.mini))
XCTAssertEqual(german.letters, .qwertz)
XCTAssertNil(german.key(.character("ü")))
XCTAssertEqual(german.keys.filter { $0.row == 2 }.compactMap(\.character), ["y", "x", "c", "v", "b", "n", "m", ",", "."])
XCTAssertEqual(AccentCatalog.options(for: "u", uppercase: false, language: .german, letters: german.letters)?.dropFirst().first, "ü")
let french = KeyboardLayout(width: 744, language: .french, pad: .docked(.mini))
XCTAssertEqual(french.keys.filter { $0.row == 2 }.compactMap { key in key.shifted.map { "\(key.character!)\($0)" } }, [",?", ".!", "':"])
let english = KeyboardLayout(width: 744, pad: .docked(.mini))
XCTAssertEqual(english.key(.character(","))?.shifted, "!")
XCTAssertEqual(english.key(.character("."))?.shifted, "?")
// The 123 and #+= pages: digits and delete, Apple's nine symbols and return, a page key
// either side of row 3; ABC where 123 was.
let numbers = KeyboardLayout(width: 744, layer: .numbers, showsGlobe: true, pad: .docked(.mini))
XCTAssertEqual(numbers.keys.filter { $0.row == 1 }.compactMap(\.character), ["@", "#", "$", "&", "*", "(", ")", "'", "\""])
XCTAssertEqual(numbers.keys.filter { $0.row == 2 && $0.kind == .layerSwitch(.symbols) }.count, 2)
let symbols = KeyboardLayout(width: 744, layer: .symbols, showsGlobe: true, pad: .docked(.mini))
XCTAssertEqual(symbols.keys.filter { $0.row == 1 }.compactMap(\.character), ["€", "£", "¥", "_", "^", "[", "]", "{", "}"])
XCTAssertEqual(symbols.keys.filter { $0.row == 3 && $0.kind == .layerSwitch(.letters) }.count, 2)
// Settings › Keyboard › Number row is iPhone only: on an iPad, docked or floating, nothing changes.
for (width, orientation, pad) in [(744.0, KeyboardOrientation.portrait, KeyboardPadPlacement.docked(.mini)), (1376, .landscape, .docked(.large)), (320, .portrait, .floating)] {
XCTAssertEqual(
KeyboardLayout(width: width, orientation: orientation, showsGlobe: true, pad: pad, numberRow: true),
KeyboardLayout(width: width, orientation: orientation, showsGlobe: true, pad: pad),
"\(pad)"
)
}
// Every language's rows fit the mini, upright and turned, and the 11- and 13-inch use them.
for language in KeyboardLanguage.allCases {
for letters in language.letterLayouts {
for (width, orientation, pad) in [(744.0, KeyboardOrientation.portrait, KeyboardPadPlacement.docked(.mini)), (1133, .landscape, .docked(.mini)), (834, .portrait, .docked(.medium)), (1376, .landscape, .docked(.large))] {
let layout = KeyboardLayout(width: width, orientation: orientation, showsGlobe: true, language: language, letters: letters, pad: pad)
let label = "\(language) \(letters) \(width)"
for row in 0..<4 {
let keys = layout.keys.filter { $0.row == row }.sorted { $0.frame.minX < $1.frame.minX }
XCTAssertEqual(keys.last!.frame.maxX, width - layout.metrics.side, accuracy: 0.01, "\(label) row \(row)")
XCTAssertGreaterThanOrEqual(keys.first!.frame.minX, layout.metrics.side - 0.01, "\(label) row \(row)")
for (l, r) in zip(keys, keys.dropFirst()) { XCTAssertEqual(r.frame.minX - l.frame.maxX, layout.metrics.gap, accuracy: 0.01, "\(label) row \(row)") }
XCTAssertTrue(keys.allSatisfy { $0.frame.width >= layout.letterWidth - 0.01 }, "\(label) row \(row)")
}
}
}
}
}
/// Docked on an iPad a held key's accents sit in Apple's cells (30 to 46.5 pt, 53 pt tall),
/// two rows once there are more than five, the key's own option nearest the key and first
/// picked, every menu inside the keyboard; floating and on an iPhone, cells stay key-wide.
@@ -1748,7 +1828,7 @@ final class KeyboardLayoutTests: XCTestCase {
continue
}
XCTAssertEqual(key.maxX, layout.width - layout.metrics.side, accuracy: 0.001, describe(layout))
XCTAssertEqual(key.width, KeyboardLayout.letterWidth(innerWidth: layout.width, metrics: layout.metrics), accuracy: 0.001, describe(layout))
XCTAssertEqual(key.width, (layout.orientation == .landscape ? 1.61 : 1.679) * (layout.width - 2 * layout.metrics.side - 10 * layout.metrics.gap) / 11.236, accuracy: 0.001, describe(layout))
XCTAssertEqual(layout.keys.filter { $0.row == 3 }.max { $0.frame.maxX < $1.frame.maxX }?.kind, .dismiss, describe(layout))
}
for layout in everyPortraitLayout() + landscapeLayouts() + duoLayouts() {
@@ -940,7 +940,7 @@ final class FullKeyboardEngine {
private func commitCharacter(_ key: KeyboardKey, at point: CGPoint, down: CGPoint? = nil) {
guard let character = key.character else { return }
spaceBeforeNextWord(character)
var text = layerState.layer == .letters && shift.isUppercase ? character.uppercased() : character
var text = layerState.layer == .letters && shift.isUppercase ? key.shifted ?? character.uppercased() : character
if layerState.layer == .letters {
shift.didType()
}
@@ -125,6 +125,14 @@ final class KeyboardKeyPlaneView: UIView {
let fill = pressed.contains(key.kind) ? palette.keyHeldFill : palette.keyFill
context.fillKeycap(frame, fill: fill, radius: radius)
guard showGlyphs() else { continue }
if let upper = key.shifted, let lower = key.character {
// The docked iPad's two-symbol keys: the shifted one over the one typed, as Apple's.
let font = UIFont.systemFont(ofSize: 18, weight: .regular)
let half = labelFrame.height / 2
drawText(upper, in: CGRect(x: labelFrame.minX, y: labelFrame.minY + 0.2 * half, width: labelFrame.width, height: half), font: font, color: palette.textBase)
drawText(lower, in: CGRect(x: labelFrame.minX, y: labelFrame.midY - 0.2 * half, width: labelFrame.width, height: half), font: font, color: palette.textBase)
continue
}
var label = Self.keycapLabel(engine.keycapLabel(for: key))
let isUpperLetter = layout.layer == .letters && engine.keycapsUppercase && label.first?.isUppercase == true
let style = isLandscape
@@ -44,6 +44,9 @@ nonisolated struct KeyboardKey: Equatable, Sendable {
/// The touch target. Hit frames tile the whole key area with no gaps.
var hitFrame: CGRect
let label: String
/// What the key types with shift instead of its character: the docked iPad's two-symbol
/// keys (, and !, . and ?), which show both (`KeyboardLayout.padPairs`).
var shifted: String?
var character: String? {
if case .character(let text) = kind { return text }
@@ -592,6 +595,8 @@ nonisolated struct KeyboardLayout: Equatable, Sendable {
/// The two halves' inner edges while the keyboard is split (the Duo unfolded upright, as
/// Apple's is there); nil otherwise.
let split: SplitGeometry?
/// Docked on an iPad, its letter keys' width (`padLetterWidth(innerWidth:...)`); nil elsewhere.
let padLetterWidth: CGFloat?
init(
width: CGFloat,
@@ -612,9 +617,13 @@ nonisolated struct KeyboardLayout: Equatable, Sendable {
availableHeight: CGFloat? = nil
) {
self.width = width
let letters = language.offered(letters)
// Apple's docked iPad German is QWERTZ without ü, ö and ä, which it holds on u, o and a
// (iPad mini, iPadOS 27.2), as Hex's plain QWERTZ does.
let offered = language.offered(letters)
let letters = pad?.isDocked == true && language == .german && offered == .own ? .qwertz : offered
self.letters = letters
self.hexPlacement = hexPlacement
// Docked on an iPad the Hex key is on the bottom row, where Apple's dictation key is.
self.hexPlacement = pad?.isDocked == true ? .leftOfSpace : hexPlacement
self.orientation = orientation
self.layer = layer
self.field = field
@@ -630,6 +639,16 @@ nonisolated struct KeyboardLayout: Equatable, Sendable {
)
if let availableHeight { metrics = metrics.fitted(toHeight: availableHeight) }
self.metrics = metrics
if metrics.pad?.isDocked == true {
padLetterWidth = Self.padLetterWidth(innerWidth: innerWidth, metrics: metrics, layer: layer, language: language, letters: letters)
self.keys = Self.buildPadKeys(
width: width, metrics: metrics, orientation: orientation, layer: layer, field: field,
showsGlobe: showsGlobe, showsEmoji: showsEmoji, inset: self.horizontalInset, language: language, letters: letters
)
self.split = nil
return
}
padLetterWidth = nil
if posture.splitsKeyboard, orientation == .portrait {
let built = Self.buildSplitKeys(
width: width,
@@ -760,6 +779,7 @@ nonisolated struct KeyboardLayout: Equatable, Sendable {
/// from it in every language, as Apple's are.
var letterWidth: CGFloat {
if isSplit { return SplitGeometry.keyWidth }
if let padLetterWidth { return padLetterWidth }
return Self.letterWidth(innerWidth: width - 2 * horizontalInset, metrics: metrics)
}
@@ -774,6 +794,7 @@ nonisolated struct KeyboardLayout: Equatable, Sendable {
/// holds 11 keys (Norwegian letters).
var characterWidth: CGFloat {
if isSplit { return SplitGeometry.keyWidth }
if let padLetterWidth { return padLetterWidth }
if layer == .letters, letters == .dvorak {
return Self.dvorakLetterWidth(innerWidth: width - 2 * horizontalInset, metrics: metrics)
}
@@ -0,0 +1,163 @@
import CoreGraphics
/// The docked iPad's own rows: Apple's iPad mini keyboard (iPadOS 27.2 simulator, black box),
/// on every iPad until the 11- and 13-inch get their own. Delete ends row 1 and return row 2,
/// a shift key opens and closes row 3, with Apple's two-symbol keys after the letters, and
/// the bottom row is the globe, 123, the Hex key where Apple's dictation key is, the space bar,
/// 123 (or emoji) and the hide-keyboard key. Key heights and rows come from `KeyboardMetrics.pad`;
/// widths follow Apple's: letter keys as wide as fits the longest row with its delete or return
/// at least 1.236 and 1.24 letters wide (English 54.5 pt, French 53.25 pt on the mini upright),
/// row 2 set in 0.4 of a key pitch (0.2 where it holds as many letters as row 1, as AZERTY's
/// does), the left shift a letter wide (1.061 on AZERTY), and delete, return and the right
/// shift taking what's left.
extension KeyboardLayout {
/// Apple's row 3 two-symbol keys: the lower one types, the upper one with shift.
static func padPairs(letters rowThree: [String], layer: KeyboardLayer) -> [(String, String?)] {
switch layer {
case .numbers:
return ["%", "-", "+", "=", "/", ";", ":"].map { ($0, nil) } + [(",", "!"), (".", "?")]
case .symbols:
return ["§", "|", "~", "…", "\\", "<", ">", "!", "?"].map { ($0, nil) }
case .letters:
switch rowThree.count {
// English, German, QWERTY and QWERTZ: , and ! then . and ?
case 7: return rowThree.map { ($0, nil) } + [(",", "!"), (".", "?")]
// AZERTY: , and ? then . and ! then ' and : (typed with shift: : , iPadOS 27.2).
case 6: return rowThree.map { ($0, nil) } + [(",", "?"), (".", "!"), ("'", ":")]
default: return rowThree.map { ($0, nil) }
}
}
}
static func padRows(layer: KeyboardLayer, language: KeyboardLanguage, letters: KeyboardLetterLayout) -> (top: [String], middle: [String], bottom: [(String, String?)]) {
let digits = "1234567890".map(String.init)
switch layer {
case .letters:
let rows = language.letterRows(letters)
return (rows[0], rows[1], padPairs(letters: rows[2], layer: .letters))
case .numbers:
return (digits, ["@", "#", "$", "&", "*", "(", ")", "'", "\""], padPairs(letters: [], layer: .numbers))
case .symbols:
return (digits, ["€", "£", "¥", "_", "^", "[", "]", "{", "}"], padPairs(letters: [], layer: .symbols))
}
}
/// Apple's minimums for the key that ends a row: delete 1.236 letters, return 1.24.
static let padDeleteRatio: CGFloat = 1.236
static let padReturnRatio: CGFloat = 1.24
/// The letter key's width on a docked iPad for these rows across `innerWidth`.
static func padLetterWidth(innerWidth: CGFloat, metrics m: KeyboardMetrics, layer: KeyboardLayer, language: KeyboardLanguage, letters: KeyboardLetterLayout) -> CGFloat {
let rows = padRows(layer: layer, language: language, letters: letters)
let available = innerWidth - 2 * m.side
let g = m.gap
let n1 = CGFloat(rows.top.count), n2 = CGFloat(rows.middle.count), n3 = CGFloat(rows.bottom.count)
let indent: CGFloat = n2 < n1 ? 0.4 : 0.2
let shift = padShiftRatio(language: language, letters: letters, layer: layer)
// Row 1: n1 letters and delete; row 2: the indent, n2 letters and return; row 3: shift,
// n3 keys and a shift as wide as delete at least.
let one = (available - n1 * g) / (n1 + padDeleteRatio)
let two = (available - (n2 + indent) * g) / (n2 + indent + padReturnRatio)
let three = (available - (n3 + 1) * g) / (shift + n3 + padDeleteRatio)
// Never wider than ten letters and delete make them (Dvorak's seven-letter row 1).
let ten = (available - 10 * g) / (10 + padDeleteRatio)
return min(one, two, three, ten)
}
static func padShiftRatio(language: KeyboardLanguage, letters: KeyboardLetterLayout, layer: KeyboardLayer) -> CGFloat {
layer == .letters && language.offered(letters) == .azerty ? 1.061 : 1
}
static func buildPadKeys(
width: CGFloat,
metrics m: KeyboardMetrics,
orientation: KeyboardOrientation,
layer: KeyboardLayer,
field: KeyboardFieldKind,
showsGlobe: Bool,
showsEmoji: Bool,
inset: CGFloat,
language: KeyboardLanguage,
letters: KeyboardLetterLayout
) -> [KeyboardKey] {
let innerWidth = width - 2 * inset
let rows = padRows(layer: layer, language: language, letters: letters)
let lw = padLetterWidth(innerWidth: innerWidth, metrics: m, layer: layer, language: language, letters: letters)
let g = m.gap, pitch = lw + g
let left = inset + m.side, right = width - inset - m.side
func rowY(_ row: Int) -> CGFloat { m.stripArea + m.keysTop + CGFloat(row) * (m.keyHeight + m.rowGap) }
var drawn: [(kind: KeyKind, row: Int, frame: CGRect, label: String, shifted: String?)] = []
func add(_ kind: KeyKind, _ row: Int, _ x: CGFloat, _ w: CGFloat, _ label: String, shifted: String? = nil) {
drawn.append((kind, row, CGRect(x: x, y: rowY(row), width: w, height: m.keyHeight), label, shifted))
}
// Row 1: the top row, then delete to the edge.
var x = left
for ch in rows.top { add(.character(ch), 0, x, lw, ch); x += pitch }
add(.delete, 0, x, right - x, "delete")
// Row 2: set in, then return to the edge.
x = left + (rows.middle.count < rows.top.count ? 0.4 : 0.2) * pitch
for ch in rows.middle { add(.character(ch), 1, x, lw, ch); x += pitch }
add(.returnKey, 1, x, right - x, "return")
// Row 3: shift (or the page switch), the letters and two-symbol keys, the other shift.
let shiftW = padShiftRatio(language: language, letters: letters, layer: layer) * lw
let page: (KeyKind, String) = switch layer {
case .letters: (.shift, "shift")
case .numbers: (.layerSwitch(.symbols), "#+=")
case .symbols: (.layerSwitch(.numbers), "123")
}
add(page.0, 2, left, shiftW, page.1)
x = left + shiftW + g
for (ch, upper) in rows.bottom { add(.character(ch), 2, x, lw, ch, shifted: upper); x += pitch }
add(page.0, 2, x, right - x, page.1)
// Row 4: globe, 123 or ABC, the Hex key (Apple's dictation key), space, the field's
// extras, 123/ABC or emoji, and hide. Apple's small keys are 1.046 letters wide upright
// and 1.02 turned, its right two 1.679 and 1.61.
// The same in every language: from row 1's letter with ten letters and delete.
let reference = (innerWidth - 2 * m.side - 10 * g) / (10 + padDeleteRatio)
let landscape = orientation == .landscape
let small = (landscape ? 1.02 : 1.046) * reference
let wide = (landscape ? 1.61 : 1.679) * reference
let pageKey: (KeyKind, String) = layer == .letters ? (.layerSwitch(.numbers), "123") : (.layerSwitch(.letters), "ABC")
var lead: [(KeyKind, CGFloat, String)] = []
if showsGlobe { lead.append((.globe, small, "globe")) }
lead.append((pageKey.0, small, pageKey.1))
lead.append((.hex, small, "hex"))
var trail: [(KeyKind, CGFloat, String)] = []
switch field {
case .text: break
case .url: trail += [(.character("."), lw, "."), (.character("/"), lw, "/")]
case .email: trail += [(.character("@"), lw, "@"), (.character("."), lw, ".")]
}
trail.append(showsEmoji && layer == .letters ? (.emoji, wide, "emoji") : (pageKey.0, wide, pageKey.1))
trail.append((.dismiss, wide, "dismiss"))
x = left
for (kind, w, label) in lead { add(kind, 3, x, w, label); x += w + g }
let trailW = trail.reduce(0) { $0 + $1.1 } + CGFloat(trail.count) * g
add(.space, 3, x, max(lw, right - trailW - x), "space")
x = right - trailW + g
for (kind, w, label) in trail { add(kind, 3, x, w, label); x += w + g }
// Targets: every gap split down the middle, the outer keys to the edges, row 1 up to the
// strip's band and row 4 to the keyboard's bottom, as the iPhone's (`buildKeys`).
let top = m.stripArea - max(m.stripBottom, stripTouchBand)
var keys: [KeyboardKey] = []
for row in 0..<4 {
let rowKeys = drawn.filter { $0.row == row }.sorted { $0.frame.minX < $1.frame.minX }
let y0 = row == 0 ? top : rowY(row) - m.rowGap / 2
let y1 = row == 3 ? m.totalHeight : rowY(row + 1) - m.rowGap / 2
for (i, item) in rowKeys.enumerated() {
let x0 = i == 0 ? 0 : (rowKeys[i - 1].frame.maxX + item.frame.minX) / 2
let x1 = i == rowKeys.count - 1 ? width : (item.frame.maxX + rowKeys[i + 1].frame.minX) / 2
var hit = CGRect(x: x0, y: y0, width: x1 - x0, height: y1 - y0)
if item.kind == .emoji {
hit = CGRect(x: item.frame.minX + 6, y: item.frame.minY + 7.5, width: item.frame.width - 12, height: y1 - item.frame.minY - 7.5)
}
keys.append(KeyboardKey(kind: item.kind, row: row, frame: item.frame, hitFrame: hit, label: item.label, shifted: item.shifted))
}
}
return keys
}
}
+24 -5
View File
@@ -1146,9 +1146,28 @@ never at a launch by itself.
27.2 simulator has Apple's off until `KeyboardShouldSplitInDefaultContext` is set).
- **iPad:** The app is iPhone-only (`TARGETED_DEVICE_FAMILY` 1), but iPadOS runs its keyboard
extension as an iPad keyboard across the screen, so the full keyboard shows there too
(Settings › Keyboard picks it or the dictation bar, as on an iPhone). It keeps the
iPhone's rows and takes Apple's iPad key sizes (`KeyboardPadSize`, `KeyboardPadPlacement`,
`KeyboardMetrics.pad`), measured beside Apple's keyboard in the iPadOS 27.2 simulator:
(Settings › Keyboard picks it or the dictation bar, as on an iPhone). Docked, it has
Apple's iPad mini rows on every iPad (`KeyboardPadRows.swift`; the 11- and 13-inch's own,
with tab, caps lock and the 13-inch's number row, are a later step): delete ends row 1 and
return row 2, a shift key opens and closes row 3, after the letters Apple's two-symbol keys
(, and ! then . and ?; AZERTY , and ?, . and !, ' and :), the shifted symbol drawn over the
one a tap types and typed with shift (`KeyboardKey.shifted`), and the bottom row the globe,
123, the Hex key where Apple's dictation key is (whatever Settings › Hex key says: the strip
is all suggestions), the space bar, emoji (or 123 when Emoji is off) where Apple's second
123 is, and the hide-keyboard key. The letter keys are as wide as the longest row allows
with its delete or return at least 1.236 and 1.24 letters wide (English 54.5 pt, French
53.25 pt on the mini upright), row 2 is set in 0.4 of a key pitch (0.2 where it holds as
many letters as row 1, as AZERTY's does), the left shift is a letter wide (1.061 on AZERTY),
and delete, return and the right shift take what's left; the bottom row's keys are the same
in every language. The 123 and #+= pages follow Apple's: digits and delete, @ # $ & * ( ) '
" (€ £ ¥ _ ^ [ ] { } on #+=) and return, a page key either side of % - + = / ; : and the two
two-symbol keys (§ | ~ … \ < > ! ? on #+=), and row 4 as the letters' with ABC; Hex has no
undo or redo key there, so ABC takes the room of Apple's undo and second ABC.
German is QWERTZ without ü, ö and ä as Apple's iPad German is, holding them on u, o and a.
Measured against Apple's iPad mini in English, German and French (every key within a point);
the other languages' rows follow the same rule unmeasured. Docked, a held key's accents open
in Apple's iPad cells (below). The sizes are Apple's iPad key sizes (`KeyboardPadSize`,
`KeyboardPadPlacement`, `KeyboardMetrics.pad`), measured beside Apple's keyboard in the iPadOS 27.2 simulator:
docked, Apple's key heights, row pitch, gaps and side inset for the iPad mini (under 800 pt
across), 11-inch and 13-inch (1,000 pt and up), upright or turned, so its four rows sit
exactly on Apple's bottom four (letters and the bottom row; the 13-inch's number row and
@@ -1160,8 +1179,8 @@ never at a launch by itself.
iPadOS always adds its own 55 pt bar above a docked keyboard (undo, redo, paste; empty in
Windowed Apps), and in some apps it draws that bar over the keyboard's top instead (Notes on
an iPad mini, iPadOS 26.6, TestFlight). So Hex is taller than Apple's (353 against 282 pt
on the mini and 11-inch upright). Docked, the bottom row ends in Apple's hide-keyboard key,
the labels keep their upright sizes turned, and keys show no balloons, as Apple's don't.
on the mini and 11-inch upright). Docked, the labels keep their upright sizes turned, and
keys show no balloons, as Apple's don't.
Floating (iPadOS makes every keyboard 320 pt wide, with no bar above and its own globe and
dictation band below), Hex is Apple's floating keyboard: 26 × 38.25 pt keys on a 54.3 pt
pitch, 35.5 pt shift and delete, 123, space and return on row 3's columns, and the strip