Context:setcapture

Controls keyboard and mouse capture.

Syntax

Signature
Context:setcapture(Keyboard: boolean, Mouse: boolean) -> ()

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
KeyboardbooleanCapture keyboard input while the context lease is active.
MousebooleanCapture mouse input inside the configured region.

Returns

TypeDescription
()None.

Notes

Call this regularly while a UI is open. Mouse capture applies inside the configured region and continues while a captured button is held. Focus loss or native editor input can suspend capture.

Example

Luau
local Context = input.createcontext()
Context:setcapture(false, true)
Context:destroy()