@puzzmo/sdk 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -127,6 +127,49 @@ sdk.gameCompleted(metrics, {
127
127
 
128
128
  The SDK automatically adds `points` and `time` deeds.
129
129
 
130
+ ## On-Screen Keyboard
131
+
132
+ For games that need text input on touch devices, the SDK can show Puzzmo's on-screen keyboard.
133
+ The keyboard is only visible on touch devices — calling these methods on desktop is a no-op.
134
+
135
+ ```ts
136
+ import { createPuzzmoSDK, defaultKeyboardConfig } from "@puzzmo/sdk"
137
+
138
+ const sdk = createPuzzmoSDK()
139
+
140
+ // Show the keyboard when the player selects an input
141
+ sdk.keyboard.show(defaultKeyboardConfig)
142
+
143
+ // Listen for key presses
144
+ sdk.on("keyboardKeyPress", ({ key }) => {
145
+ if (key === "⌫") handleBackspace()
146
+ else if (key === "↵") handleEnter()
147
+ else handleLetter(key)
148
+ })
149
+
150
+ // Hide when input is dismissed
151
+ sdk.keyboard.hide()
152
+ ```
153
+
154
+ `defaultKeyboardConfig` is a standard QWERTY layout with Enter and Backspace. Customize it by spreading:
155
+
156
+ ```ts
157
+ // Disable letters that are no longer valid given the current game state
158
+ sdk.keyboard.show({ ...defaultKeyboardConfig, disabled: usedLetters })
159
+ ```
160
+
161
+ For games with a spatial input model (e.g. selecting a grid cell by dragging across the keyboard),
162
+ enable drag cursor support and listen for the additional events:
163
+
164
+ ```ts
165
+ sdk.keyboard.show({ ...defaultKeyboardConfig, supportsDragCursor: true })
166
+
167
+ sdk.on("keyboardCursorChange", ({ position }) => highlightCellAtPosition(position))
168
+ sdk.on("keyboardCursorEnd", () => confirmCellSelection())
169
+ ```
170
+
171
+ See the `KeyboardConfig` type export and the `add-keyboard-support` skill for full field documentation.
172
+
130
173
  ## App Integration
131
174
 
132
175
  For games to show a dynamic thumbnail, you will need an App Bundle