diff --git a/ios/HEXMobile/Localizable.xcstrings b/ios/HEXMobile/Localizable.xcstrings index d3e191decb..ccd0fca0d8 100644 --- a/ios/HEXMobile/Localizable.xcstrings +++ b/ios/HEXMobile/Localizable.xcstrings @@ -1681,6 +1681,16 @@ } } }, + "Key flicks" : { + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "按键轻扫" + } + } + } + }, "Key pop-ups" : { "localizations" : { "zh-Hans" : { @@ -4273,6 +4283,16 @@ } } }, + "Pull a key down to type the character above its letter" : { + "localizations" : { + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "向下拉按键即可输入其字母上方的字符" + } + } + } + }, "The multilingual model's download stopped. Trying again in %lld s." : { "localizations" : { "zh-Hans" : { diff --git a/ios/HEXMobile/Settings/KeyboardSettingsPage.swift b/ios/HEXMobile/Settings/KeyboardSettingsPage.swift index f58c0837f0..23976cee41 100644 --- a/ios/HEXMobile/Settings/KeyboardSettingsPage.swift +++ b/ios/HEXMobile/Settings/KeyboardSettingsPage.swift @@ -72,6 +72,10 @@ struct KeyboardSettingsPage: View { private var settings: FullKeyboardSettings { FullKeyboardSettings() } + /// Hex is an iPhone app, so on an iPad its idiom says phone; the device's model doesn't. + /// There the keyboard has Apple's iPad rows: no number row, and key flicks instead. + private static let runsOnIPad = UIDevice.current.model.hasPrefix("iPad") + private var fullKeyboard: Bool { _ = revision return settings.isEnabled @@ -204,11 +208,19 @@ struct KeyboardSettingsPage: View { SettingsDivider() - SettingsToggleRow( - title: String(localized: "Number row"), - detail: String(localized: "Shows 1 to 0 above the letters"), - isOn: binding(\.numberRow) - ) + if Self.runsOnIPad { + SettingsToggleRow( + title: String(localized: "Key flicks"), + detail: String(localized: "Pull a key down to type the character above its letter"), + isOn: binding(\.keyFlicks) + ) + } else { + SettingsToggleRow( + title: String(localized: "Number row"), + detail: String(localized: "Shows 1 to 0 above the letters"), + isOn: binding(\.numberRow) + ) + } } } diff --git a/ios/HEXMobileTests/FullKeyboardEngineTests+SwipeTyping.swift b/ios/HEXMobileTests/FullKeyboardEngineTests+SwipeTyping.swift index ee3ac0b48f..c8c23fc1cb 100644 --- a/ios/HEXMobileTests/FullKeyboardEngineTests+SwipeTyping.swift +++ b/ios/HEXMobileTests/FullKeyboardEngineTests+SwipeTyping.swift @@ -136,6 +136,45 @@ extension FullKeyboardEngineTests { XCTAssertEqual(rowOne.text, "power") } + /// TestFlight build 147 (iPad): "flick for symbol is not working". On a docked iPad, pulling + /// a key down past half its travel types the character over its letter, as Apple's key + /// flicks do; a short pull, a pull taken back, or the switch off types the letter. The pull + /// keeps its key (no slide onto the row below), a rollover types the flicked character, and + /// a digit goes in as typed, with nothing corrected. + func testDockedIPadKeyFlicks() throws { + engine.pad = .docked(.mini) + defer { KeyboardFlicks.isEnabled = true } + let e = try XCTUnwrap(engine.layout.key(.character("e"))) + XCTAssertEqual(e.flick, "3") + let start = CGPoint(x: e.frame.midX, y: e.frame.midY) + func pull(_ dy: CGFloat, back: Bool = false, id: Int = 1, lift: Bool = true) { + engine.touchBegan(id: id, at: start) + for step in stride(from: CGFloat(3), through: dy, by: 3) { + engine.touchMoved(id: id, to: CGPoint(x: start.x, y: start.y + step)) + } + if back { engine.touchMoved(id: id, to: start) } + if lift { engine.touchEnded(id: id, at: CGPoint(x: start.x, y: start.y + (back ? 0 : dy))) } + } + pull(30) + XCTAssertEqual(target.text, "3") + pull(12) + XCTAssertEqual(target.text, "3e", "a short pull types the letter") + pull(30, back: true) + XCTAssertEqual(target.text, "3ee", "taken back, the letter") + pull(60) + XCTAssertEqual(target.text, "3ee3", "past the row below, still the flick") + pull(30, lift: false) + XCTAssertEqual(engine.touches[1]?.key.kind, .character("e")) + tap(.character("r")) + engine.touchEnded(id: 1, at: CGPoint(x: start.x, y: start.y + 30)) + XCTAssertEqual(target.text, "3ee33r", "rollover types the flicked character") + KeyboardFlicks.isEnabled = false + pull(30) + XCTAssertEqual(target.text, "3ee33re", "Settings › Keyboard › Key flicks off") + engine.pad = nil + XCTAssertNil(engine.layout.key(.character("e"))?.flick, "an iPhone has none") + } + /// Without the switch, or on an iPad, the keys have no number row. func testNumberRowNeedsItsSwitchAndAnIPhone() { XCTAssertFalse(engine.layout.hasNumberRow, "off by default") diff --git a/ios/HEXMobileTests/KeyboardLayoutTests.swift b/ios/HEXMobileTests/KeyboardLayoutTests.swift index fbcf49037c..79714638df 100644 --- a/ios/HEXMobileTests/KeyboardLayoutTests.swift +++ b/ios/HEXMobileTests/KeyboardLayoutTests.swift @@ -3504,4 +3504,24 @@ final class FullKeyboardSettingsTests: XCTestCase { XCTAssertTrue(settings.quickAccents) XCTAssertEqual(defaults.object(forKey: "experiments.quickAccents") as? Bool, true) } + + /// Apple's key flicks over the docked iPad's keys (iPad mini, iPadOS 27.2): digits over row 1, + /// @ # $ & * ( ) ' " over row 2 and % - + = / ; : over row 3 in English and German, AZERTY's + /// own in French, the #+= page's characters over the 123 page's symbols, nothing on the + /// two-symbol keys or the floating keyboard. + func testDockedIPadKeysCarryApplesKeyFlicks() { + func flicks(_ language: KeyboardLanguage, _ layer: KeyboardLayer = .letters, pad: KeyboardPadPlacement = .docked(.mini)) -> [String] { + let layout = KeyboardLayout(width: 744, layer: layer, language: language, pad: pad) + return (0..<3).map { row in + layout.keys.filter { $0.row == row }.sorted { $0.frame.minX < $1.frame.minX }.compactMap(\.flick).joined() + } + } + XCTAssertEqual(flicks(.english), ["1234567890", "@#$&*()'\"", "%-+=/;:"]) + XCTAssertEqual(flicks(.german), ["1234567890", "@#$&*()'\"", "%-+=/;:"]) + XCTAssertEqual(flicks(.french), ["1234567890", "@#&\"$(!)-*", "%_+=/;"]) + XCTAssertEqual(flicks(.english, .numbers), ["", "€£¥_^[]{}", "§|~…\\<>"]) + XCTAssertEqual(flicks(.english, .symbols), ["", "", ""]) + XCTAssertEqual(flicks(.english, pad: .floating), ["", "", ""]) + XCTAssertNil(KeyboardLayout(width: 744, layer: .letters, pad: .docked(.mini)).key(.character(","))?.flick) + } } diff --git a/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine+Flicks.swift b/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine+Flicks.swift new file mode 100644 index 0000000000..81aedc892a --- /dev/null +++ b/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine+Flicks.swift @@ -0,0 +1,43 @@ +import CoreGraphics + +/// Key flicks on a docked iPad (`KeyboardFlicks`): a key pulled down types the character +/// over its letter. +@MainActor +extension FullKeyboardEngine { + /// A move of a key that flicks: once the finger has gone down more than across, the touch + /// keeps its key (no slide to the key below, no swipe) and its pull is tracked. False for + /// every other touch, which moves as before. + func moveFlick(_ touch: inout ActiveTouch, id: Int, to point: CGPoint) -> Bool { + guard KeyboardFlicks.isEnabled, layout.metrics.pad?.isDocked == true, !touch.committed, + touch.key.flick != nil, activeAccentMenu == nil else { return false } + let dy = point.y - touch.startPoint.y + let dx = abs(point.x - touch.startPoint.x) + if touch.flick == nil { + guard dy > 4, dy > dx else { return false } + } + let progress = KeyboardFlicks.progress(pull: dy) + guard progress != touch.flick else { + touches[id] = touch + return true + } + touch.flick = progress + touches[id] = touch + onChange?() + return true + } + + /// Letting go of a pulled key: past half way, its character goes in as a typed one (as a + /// slide from 123 does: a mark after a word corrects it, a digit is just a digit). False + /// otherwise, and the letter goes in. + func commitFlick(_ touch: ActiveTouch) -> Bool { + guard let progress = touch.flick, progress >= KeyboardFlicks.commitProgress, let character = touch.key.flick else { return false } + typingLog?.ui("flick", [TypingLogField("key", .string(touch.key.label)), TypingLogField("chosen", .string(character))]) + if dropsSuggestionSpace(before: character) || !correctWord(endingWith: character) { + insert(character, source: "flick") + } + if layerState.layer == .letters { shift.didType() } + refreshAutoCapitalization() + logState("typed") + return true + } +} diff --git a/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine.swift b/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine.swift index 32ab3e35c5..858bf801f1 100644 --- a/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine.swift +++ b/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine.swift @@ -28,10 +28,10 @@ final class FullKeyboardEngine { /// How far along the space bar a language swipe must go; a shorter one types a space. static let languageSwipeDistance: CGFloat = 24 - private(set) var shift = ShiftStateMachine() + var shift = ShiftStateMachine() var layerState = KeyboardLayerState() private(set) var field: KeyboardFieldKind = .text - private(set) var touches: [Int: ActiveTouch] = [:] + var touches: [Int: ActiveTouch] = [:] /// Touch ids in the order they went down. private var touchOrder: [Int] = [] var lastSpaceAt: TimeInterval? @@ -500,7 +500,7 @@ final class FullKeyboardEngine { commitAccentSelection(menu.selectedOption) activeAccentMenu = nil activeAccentTouchID = nil - } else { + } else if !commitFlick(touch) { commitCharacter(touch.key, at: touch.startPoint, down: touch.downPoint) } touch.committed = true @@ -663,6 +663,7 @@ final class FullKeyboardEngine { return } + if moveFlick(&touch, id: id, to: point) { return } // 4. Sliding across character keys updates the active key and re-anchors the hold timer. // A letter the next-letter odds claimed keeps the touch while it stays within reach. if touch.key.character != nil, !touch.committed, @@ -736,7 +737,7 @@ final class FullKeyboardEngine { switch touch.key.kind { case .character: - if !touch.committed { + if !touch.committed, !commitFlick(touch) { commitCharacter(touch.key, at: touch.startPoint, down: touch.downPoint) } case .shift: @@ -966,7 +967,7 @@ final class FullKeyboardEngine { /// Punctuation right after a word corrects it as space does ("teh," becomes "the,"), and /// goes in after the fix. Delete right after takes only the mark, as after a space. /// False when there is nothing to fix: the caller types the mark as usual. - private func correctWord(endingWith text: String) -> Bool { + func correctWord(endingWith text: String) -> Bool { guard text.count == 1, let mark = text.first, Self.wordEnders.contains(mark), swipedWord == nil else { return false } if applyTextReplacement(ending: text) { return true } let before = textBefore diff --git a/ios/HEXShared/FullKeyboard/FullKeyboardSettings.swift b/ios/HEXShared/FullKeyboard/FullKeyboardSettings.swift index afa8bac8cd..f880e95904 100644 --- a/ios/HEXShared/FullKeyboard/FullKeyboardSettings.swift +++ b/ios/HEXShared/FullKeyboard/FullKeyboardSettings.swift @@ -95,6 +95,7 @@ struct FullKeyboardSettings { static let hideWordSuggestions = "experiments.hideWordSuggestions" static let hexKeyOnLeft = "settings.keyboardHexKeyLeft" static let numberRow = "settings.keyboardNumberRow" + static let keyFlicks = "settings.keyboardKeyFlicks" static let dictationBarAutoStart = "settings.dictationBarAutoStart" static let joinKeyboardWhenUnfolded = "experiments.joinKeyboardWhenUnfolded" static let dvorakPunctuation = "experiments.dvorakPunctuation" @@ -324,6 +325,14 @@ struct FullKeyboardSettings { nonmutating set { defaults?.set(newValue, forKey: Key.numberRow) } } + /// Settings › Keyboard › Key flicks (iPad): pulling a docked iPad key down types the + /// character over its letter, as Apple's keyboard does (`KeyboardFlicks`). On by default, as + /// Apple's Enable Key Flicks is; a keyboard extension can't read that one. + var keyFlicks: Bool { + get { defaults?.object(forKey: Key.keyFlicks) as? Bool ?? true } + nonmutating set { defaults?.set(newValue, forKey: Key.keyFlicks) } + } + /// Settings › Experiments › Join the keyboard when unfolded: on the Duo unfolded and held /// upright, Hex normally splits its keyboard as Apple's does there, since an extension /// can't read Apple's Split Keyboard preference. On, it draws the joined keyboard instead, diff --git a/ios/HEXShared/FullKeyboard/FullKeyboardTouch.swift b/ios/HEXShared/FullKeyboard/FullKeyboardTouch.swift index 8c24b3f1b2..9855f4b426 100644 --- a/ios/HEXShared/FullKeyboard/FullKeyboardTouch.swift +++ b/ios/HEXShared/FullKeyboard/FullKeyboardTouch.swift @@ -37,6 +37,9 @@ extension FullKeyboardEngine { var claimed = false /// Where the finger went down, before a strip touch moved onto row 1 (Adaptive touch). var downPoint: CGPoint = .zero + /// A docked iPad key pulled down (`KeyboardFlicks`): how far its character has come, 0 to 1; + /// nil until the finger goes down more than across. + var flick: CGFloat? } /// A press that types the character key it slides onto: 123, ABC and #+= (with a page to diff --git a/ios/HEXShared/FullKeyboard/KeyboardFlicks.swift b/ios/HEXShared/FullKeyboard/KeyboardFlicks.swift new file mode 100644 index 0000000000..c88a66ecd3 --- /dev/null +++ b/ios/HEXShared/FullKeyboard/KeyboardFlicks.swift @@ -0,0 +1,76 @@ +import CoreGraphics + +/// Apple's key flicks on the docked iPad keyboard (Settings › General › Keyboard › Enable Key +/// Flicks): every letter key carries a small grey character above its letter, and pulling the +/// key down types it. Read on Apple's iPad mini keyboard (iPadOS 27.2 simulator, black box, +/// 2026-11-23), the rows Hex draws on every docked iPad (`KeyboardPadRows.swift`): +/// +/// - English and German: 1 to 0 over row 1, @ # $ & * ( ) ' " over row 2, % - + = / ; : over +/// row 3; French (AZERTY): 1 to 0, @ # & " $ ( ! ) - *, and % _ + = / ;. +/// - The 123 page: the #+= page's character over each symbol (€ over @, § over %), not on the +/// digits. +/// - The two-symbol keys after the letters keep their own pair and flick nothing. +/// +/// Drawn about 12.5 pt high in a grey a little above the key's middle top, the letter set +/// lower; while pulled, the character slides down to the middle and darkens as the letter +/// fades (none of it moves at 8 pt, about half way at 16 pt, all the way by 30 pt). A +/// keyboard extension can't read Apple's switch (the Custom Keyboard guide: no access to the +/// general keyboard settings), so Hex has its own (Settings › Keyboard › Key flicks). +nonisolated enum KeyboardFlicks { + /// Settings › Keyboard › Key flicks, set by the keyboard view from the App Group. + nonisolated(unsafe) static var isEnabled = true + + /// No change below this pull (pt). + static let start: CGFloat = 8 + /// Pull (pt) from `start` to the character in place. + static let travel: CGFloat = 18 + /// Let go at or past this share of the way and the character goes in; short of it (or + /// pulled back up), the letter. + static let commitProgress: CGFloat = 0.5 + + /// How far a pull of `dy` points down has brought the character, 0 to 1. + static func progress(pull dy: CGFloat) -> CGFloat { + min(1, max(0, (dy - start) / travel)) + } + + private static let digits = "1234567890".map(String.init) + private static let englishMiddle = ["@", "#", "$", "&", "*", "(", ")", "'", "\""] + private static let englishBottom = ["%", "-", "+", "=", "/", ";", ":"] + private static let frenchMiddle = ["@", "#", "&", "\"", "$", "(", "!", ")", "-", "*"] + private static let frenchBottom = ["%", "_", "+", "=", "/", ";"] + /// The 123 page's symbols and the #+= page's character Apple puts over each. + private static let numbersPage: [String: String] = [ + "@": "€", "#": "£", "$": "¥", "&": "_", "*": "^", "(": "[", ")": "]", "'": "{", "\"": "}", + "%": "§", "-": "|", "+": "~", "=": "…", "/": "\\", ";": "<", ":": ">", + ] + + /// Each key's flick on the letters and 123 pages. Measured for English, German and French; + /// every other language gets the digits over a ten-letter row 1 (Apple's own for them + /// unmeasured), and rows 2 and 3 only where they have English's nine and seven letters. + static func add(to keys: inout [KeyboardKey], layer: KeyboardLayer, language: KeyboardLanguage) { + switch layer { + case .symbols: + return + case .numbers: + for i in keys.indices where keys[i].shifted == nil && keys[i].row > 0 { + if let c = keys[i].character { keys[i].flick = numbersPage[c] } + } + case .letters: + let measured = language == .english || language == .german + let rows: [[String]] = language.isFrench + ? [digits, frenchMiddle, frenchBottom] + : [digits, measured ? englishMiddle : [], measured ? englishBottom : []] + for row in 0..<3 { + let letters = keys.indices + .filter { keys[$0].row == row && keys[$0].shifted == nil && keys[$0].character?.first?.isLetter == true } + .sorted { keys[$0].frame.minX < keys[$1].frame.minX } + let flicks = rows[row] + if row == 0, letters.count != 10 { continue } + if row > 0, !language.isFrench, letters.count != flicks.count { continue } + for (n, i) in letters.enumerated() where n < flicks.count { + keys[i].flick = flicks[n] + } + } + } + } +} diff --git a/ios/HEXShared/FullKeyboard/KeyboardKeyPlaneView.swift b/ios/HEXShared/FullKeyboard/KeyboardKeyPlaneView.swift index b3e10f2f29..b467c1ff47 100644 --- a/ios/HEXShared/FullKeyboard/KeyboardKeyPlaneView.swift +++ b/ios/HEXShared/FullKeyboard/KeyboardKeyPlaneView.swift @@ -134,6 +134,10 @@ final class KeyboardKeyPlaneView: UIView { drawText(lower, in: CGRect(x: labelFrame.minX, y: labelFrame.midY - 0.2 * half, width: labelFrame.width, height: half), font: font, color: palette.textBase) continue } + if KeyboardFlicks.isEnabled, let flick = key.flick, layout.metrics.pad?.isDocked == true { + drawFlickKey(key, flick: flick, in: labelFrame) + continue + } var label = Self.keycapLabel(engine.keycapLabel(for: key)) let isUpperLetter = layout.layer == .letters && engine.keycapsUppercase && label.first?.isUppercase == true var style = isLandscape @@ -243,6 +247,28 @@ final class KeyboardKeyPlaneView: UIView { } } + /// A docked iPad key with a flick (`KeyboardFlicks`), as Apple's draws it (iPad mini, iPadOS + /// 27.2): the flick character about 12.5 pt high, grey, centred 14.5 pt below a 55.5 pt + /// keycap's top, and the label 11 pt below the middle. Pulled, the character slides to the + /// middle at the label's size, darkening as the label fades (both by half way); with Reduce Motion it + /// takes the label's place at once, half way. + private func drawFlickKey(_ key: KeyboardKey, flick: String, in frame: CGRect) { + let pulled = engine.touches.values.first { $0.key.kind == key.kind && $0.flick != nil }?.flick ?? 0 + let p = UIAccessibility.isReduceMotionEnabled ? (pulled >= KeyboardFlicks.commitProgress ? 1 : 0) : pulled + let scale = frame.height / 55.5 + let labelText = Self.keycapLabel(engine.keycapLabel(for: key)) + let labelFont = UIFont.systemFont(ofSize: 21 * scale, weight: .regular) + if p < 1 { + let labelFrame = frame.offsetBy(dx: 0, dy: (11 + 8 * p) * scale) + drawText(labelText, in: labelFrame, font: labelFont, color: palette.textBase.withAlphaComponent(max(0, 1 - 2 * p))) + } + let size = (13 + 8 * p) * scale + let centre = frame.minY + (14.5 + (frame.height / scale / 2 - 14.5) * p) * scale + let flickFrame = CGRect(x: frame.minX, y: centre - frame.height / 2, width: frame.width, height: frame.height) + let color = palette.textBase.withAlphaComponent(0.45 + 0.55 * min(1, 2 * p)) + drawText(flick, in: flickFrame, font: UIFont.systemFont(ofSize: size, weight: .regular), color: color) + } + /// `rect` with its edges on this screen's pixel grid. private func pixelAligned(_ rect: CGRect) -> CGRect { let scale = max(1, traitCollection.displayScale) @@ -560,6 +586,8 @@ final class KeyboardKeyPlaneView: UIView { engine.touchMoved(id: id, to: sample.point, time: sample.timestamp) let current = engine.touches[id]?.key typingLog?.touch(.moved, id: id, sample: sample, key: current, under: engine.layout.hitTest(sample.point)) + // A pulled key flicks: its hold opens no accents. + if engine.touches[id]?.flick != nil { cancelAccentTimer(for: id) } if current?.kind != previousKey { cancelAccentTimer(for: id) if case .character = current?.kind { diff --git a/ios/HEXShared/FullKeyboard/KeyboardLayout.swift b/ios/HEXShared/FullKeyboard/KeyboardLayout.swift index 604d3c9ab7..e4aed6f28c 100644 --- a/ios/HEXShared/FullKeyboard/KeyboardLayout.swift +++ b/ios/HEXShared/FullKeyboard/KeyboardLayout.swift @@ -41,6 +41,9 @@ nonisolated struct KeyboardKey: Equatable, Sendable { /// keys (, and !, . and ?), which show both (`KeyboardLayout.padPairs`), and the Dvorak /// punctuation keys (<, > and :). var shifted: String? + /// What pulling the key down types, drawn small above its label: Apple's key flicks on a + /// docked iPad (`KeyboardFlicks`); nil elsewhere. + var flick: String? var character: String? { if case .character(let text) = kind { return text } diff --git a/ios/HEXShared/FullKeyboard/KeyboardPadRows.swift b/ios/HEXShared/FullKeyboard/KeyboardPadRows.swift index 7a63c681ab..8b6dfc01e6 100644 --- a/ios/HEXShared/FullKeyboard/KeyboardPadRows.swift +++ b/ios/HEXShared/FullKeyboard/KeyboardPadRows.swift @@ -155,6 +155,7 @@ extension KeyboardLayout { keys.append(KeyboardKey(kind: item.kind, row: row, frame: item.frame, hitFrame: hit, label: item.label, shifted: item.shifted)) } } + KeyboardFlicks.add(to: &keys, layer: layer, language: language) return keys } } diff --git a/ios/HEXShared/FullKeyboard/SwipeTyping.swift b/ios/HEXShared/FullKeyboard/SwipeTyping.swift index d86183925a..23494c1360 100644 --- a/ios/HEXShared/FullKeyboard/SwipeTyping.swift +++ b/ios/HEXShared/FullKeyboard/SwipeTyping.swift @@ -123,7 +123,7 @@ final class SwipeTyping { pending[id] = stroke guard let first = stroke.points.first, hypot(point.x - first.x, point.y - first.y) > threshold, let touch = engine.touches[id], !touch.committed, engine.activeAccentMenu == nil, - engine.allowsSwipes else { return false } + touch.flick == nil, engine.allowsSwipes else { return false } pending[id] = nil syncWords() engine.beginSwipe(touchID: id) diff --git a/ios/HEXShared/FullKeyboard/View/FullKeyboardView+Settings.swift b/ios/HEXShared/FullKeyboard/View/FullKeyboardView+Settings.swift index 8c32ae988d..ffb004186b 100644 --- a/ios/HEXShared/FullKeyboard/View/FullKeyboardView+Settings.swift +++ b/ios/HEXShared/FullKeyboard/View/FullKeyboardView+Settings.swift @@ -19,8 +19,13 @@ extension FullKeyboardView { } /// Settings › Keyboard › Number row: the keyboard grows by the row, so the host is asked - /// for the new height. + /// for the new height. Settings › Keyboard › Key flicks (iPad) is read here too. func syncNumberRow() { + let flicks = FullKeyboardSettings().keyFlicks + if KeyboardFlicks.isEnabled != flicks { + KeyboardFlicks.isEnabled = flicks + plane.setNeedsDisplay() + } let shows = FullKeyboardSettings().numberRow guard engine.showsNumberRow != shows else { return } plane.cancelAllTouches() diff --git a/ios/docs/keyboard.md b/ios/docs/keyboard.md index 5cde848145..e22c2a8f8b 100644 --- a/ios/docs/keyboard.md +++ b/ios/docs/keyboard.md @@ -820,7 +820,8 @@ Spatial autocorrect, next-letter touch help or Swipe typing (a drag from a digit swipe), and a word holding digits is never corrected. Where iOS gives less height, the number row shrinks with the others (`KeyboardMetrics.fitted`). The iPad keeps Apple's rows for now: its docked keyboards would need Apple's own number row on the 13-inch and room -above the strip on the others. +above the strip on the others. There the switch is hidden (Hex is an iPhone app, so the page +reads the device's model, not its idiom), and Key flicks takes its place. ## Web search fields (full keyboard) @@ -950,7 +951,28 @@ two-symbol keys (§ | ~ … \ < > ! ? on #+=), and row 4 as the letters' with AB 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 +the other languages' rows follow the same rule unmeasured. **Key flicks** (Settings › +Keyboard › Key flicks, on by default, shown only on an iPad; `settings.keyboardKeyFlicks`, +App Group): as on Apple's mini and 11-inch keyboards, every docked letter key carries a small +grey character over its letter, and pulling the key down types it (`KeyboardFlicks`): 1 to 0 +over row 1, @ # $ & * ( ) ' " over row 2 and % - + = / ; : over row 3 in English and German, +AZERTY's own (@ # & " $ ( ! ) - *, % _ + = / ;) in French, and on the 123 page the #+= page's +character over each symbol (€ over @, § over %); the two-symbol keys and the digits keep +none. Other languages get the digits over a ten-letter row 1, and rows 2 and 3 only with +English's nine and seven letters (Apple's own for them unmeasured). Drawn as Apple's (iPad +mini, iPadOS 27.2): the character about 12.5 pt high and grey, 14.5 pt below the keycap's +top, the letter 11 pt below the middle. Once the finger has gone down more than across, the +key keeps the touch: no slide onto the key below and no swipe (a swipe still starts any other +way); from 8 pt down the character slides to the middle, growing and darkening as the letter +fades, all the way by 26 pt; let go past half way (17 pt) and it goes in as a typed character +(a mark after a word corrects it, as a slide from 123 does; a digit is just a digit), short +of it or pulled back, the letter. A rollover commits it the same way. With Reduce Motion the +character takes the letter's place at once, half way. Holding first opens the key's accents, +as before, and the pull then moves through them. Apple's own switch (Settings › General › +Keyboard › Enable Key Flicks) can't be read by a keyboard extension, hence Hex's. Typing +logs mark it `ui flick` and `insert` `src: flick`. On the simulator Apple's keys animate +the pull the same way but synthetic touches never made one type its character, so where it +commits is Hex's choice, not a measurement. Never on the floating keyboard or an iPhone. 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 diff --git a/ios/docs/typing-logs.md b/ios/docs/typing-logs.md index 5a832dce94..382aff7121 100644 --- a/ios/docs/typing-logs.md +++ b/ios/docs/typing-logs.md @@ -180,7 +180,7 @@ cursor, for every `edit` (and `dictation`) line remove `deleted` (a string; | `op` | fields | | --- | --- | -| `insert` | `inserted`, `src`: `key` (a character or space), `accent` (long-press pick), `slide` (hold 123, slide, let go), `bar` (the dictation bar's space) | +| `insert` | `inserted`, `src`: `key` (a character or space), `accent` (long-press pick), `slide` (hold 123, slide, let go), `flick` (a docked iPad key pulled down: the character over its letter), `bar` (the dictation bar's space) | | `delete` | `deleted` (the character), `src`: `key` (on press), `repeat` (held, 75 ms), `repeat_fast` (after 0.85 s, two at a time), `bar`, `selection` (Two-thumb selection's Delete), `selection_cut`, `selection_dictate` (its Dictate, when the dictation's words arrive and replace the range; `deletedCount` when the range is longer than 80 characters) | | `delete_word` | `deleted`, `src`: `repeat_word` (held past 1.4 s) | | `autocorrect` | `from`, `to`, `deleted` (= `from`), `inserted` (`to` + space). Applied on space. | @@ -221,6 +221,8 @@ Taps that aren't text: `action`: - `accent_open` (`id`, `key`, `options`), `accent_pick` (`id`, `index`, `chosen`, `rollover` when another key committed it), `accent_cancel`; +- `flick` (`key`, the pulled key's label; `chosen`, what went in): a docked iPad key let go + past half its pull (Settings › Keyboard › Key flicks), followed by an `insert` with `src: flick`; - `trackpad_start` (`id`; `hold: true`, as only holding the space bar starts it; older logs without it had a 10 pt slide start it), `trackpad_end` (`id`, `offset`: total UTF-16 units; with Two-thumb selection on, the space bar's own lift writes it even while the