Knowledge from the fieldRedM

DisplayOnscreenKeyboard: poll UpdateOnscreenKeyboard() — 1=entered, 2=cancelled; title must be an AddTextEntry key

learning:55

DisplayOnscreenKeyboard: poll UpdateOnscreenKeyboard() — 1=entered, 2=cancelled; title must be an AddTextEntry key

Context

The on-screen keyboard is asynchronous and its result must be polled. Reading the result without checking status returns stale or nil data.

The pattern

AddTextEntry("FMMC_KEY_TIP1", label)                 -- register a text-entry KEY
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", default, "", "", "", maxLength)
while true do
  Wait(0)
  local status = UpdateOnscreenKeyboard()            -- must call every frame
  if status == 1 then return GetOnscreenKeyboardResult()  -- entered
  elseif status == 2 then return nil end             -- cancelled
end

The trap

  • The title/description args are text-entry keys, not literal strings — register them with AddTextEntry first.
  • UpdateOnscreenKeyboard() returns 1 (entered), 2 (cancelled), or other (still open). Only read GetOnscreenKeyboardResult() on 1; otherwise you get stale/nil.

Verified

input/client.lua:12-26. The native documents the textType enum but not the status-code polling contract.


Tags: input, keyboard, updateonscreenkeyboard, polling, addtextentry, hud
Category: natives
Source: jo_libs-fleet
Created: 2026-05-31T09:40:26.134Z

Back to documentation