keystroke

open override fun keystroke(fieldName: String, change: String, selectionStart: Int, selectionEnd: Int): String?

The viewer's keystroke: the value the field should show, or null when a script refused it.


fun keystroke(fieldName: String, change: String, selectionStart: Int = (formState.value(fieldName) ?: "").length, selectionEnd: Int = selectionStart, commit: Boolean = false): PdfScriptRunner.KeystrokeResult

Runs a field's keystroke script for one edit, without committing it (ISO 32000-1 §12.6.3). A viewer calls this for each character the reader types, so a script can refuse it.

change is what is being inserted, and selectionStart and selectionEnd say what it replaces.