Type Index Pages
- BillboardGui
- Frame
- Hint
- ImageButton
- ImageLabel
- PlayerGui
- ScreenGui
- ScrollingFrame
- StarterGui
- SurfaceGui
- TextBox
- TextButton
- TextLabel
- UIAspectRatioConstraint
- UIGradient
- UIGridLayout
- UIInlineLayout
- UIListLayout
- UIPadding
- UIPageLayout
- UIScale
- UISizeConstraint
- UITableLayout
- UITextSizeConstraint
- VideoFrame
- ViewportFrame
- ChangeHistoryService
- CoreGui
- DataModelSession
- DockWidgetPluginGui
- MultipleDocumentInterfaceInstance
- Plugin
- PluginAction
- PluginGui
- PluginGuiService
- PluginManager
- PluginMenu
- PluginMouse
- PluginToolbar
- PluginToolbarButton
- QWidgetPluginGui
- Selection
- StandalonePluginScripts
- StatsItem
- StudioService
- StudioTheme
No results found!
-
Instance
- GameSettings
- DebugSettings
- BodyMover
- WeldConstraint
- HttpRbxApiService
- NotificationService
- Translator
- Lighting
- Beam
- GuiService
- UserInputService
- Studio
- Plugin
- HttpService
- Mouse
- BindableEvent
- RunService
- Pages
- Humanoid
- TestService
- PathfindingService
- Chat
- NetworkPeer
- Feature
- CharacterAppearance
- Constraint
- NetworkReplicator
- JointInstance
- Light
- BasePlayerGui
- AnalyticsService
- NetworkMarker
- BinaryStringValue
- FlyweightService
- Geometry
- LoginService
- InstancePacketCache
- ThirdPartyUserService
- TouchInputService
- RuntimeScriptService
- GuidRegistryService
- PartOperationAsset
- DialogChoice
- PhysicsService
- AdService
- TextService
- MarketplaceService
- TeleportService
- Accoutrement
- GamePassService
- AssetService
- InsertService
- PointsService
- ChangeHistoryService
- ServerScriptService
- JointsService
- LogService
- InputObject
- Toolbar
- LuaSettings
- RenderSettings
- AnimationTrack
- PhysicsSettings
- NetworkSettings
- CFrameValue
- Animation
- Color3Value
- BoolValue
- BrickColorValue
- Vector3Value
- AnimationController
- BindableFunction
- Button
- Trail
- LocalizationTable
- LocalizationService
- DebuggerBreakpoint
- DebuggerWatch
- ScriptDebugger
- Animator
- Attachment
- RemoteFunction
- RemoteEvent
- PluginManager
- Camera
- Stats
- Sky
- StarterPlayer
- Dragger
- TerrainRegion
- Path
- TextFilterResult
- Dialog
- StatsItem
- GoogleAnalyticsConfiguration
- ScriptContext
- ControllerService
- CacheableContentProvider
- ReflectionMetadataClasses
- ReflectionMetadataEnums
- DebuggerManager
- GuiBase
- UIBase
- LuaSourceContainer
- GuiItem
- DataModelMesh
- ServiceProvider
- ReflectionMetadataItem
- PostEffect
- PhysicsPacketCache
- TouchTransmitter
- RobloxReplicatedStorage
- Visit
- LuaWebService
- ScriptService
- FlagStandService
- VirtualUser
- SpawnerService
- TimerService
- CookiesService
- Team
- GroupService
- StarterGear
- Message
- PlayerScripts
- Configuration
- ContentProvider
- CollectionService
- Debris
- ReplicatedFirst
- ServerStorage
- ReplicatedStorage
- Folder
- TweenService
- Players
- ContextActionService
- StarterPlayerScripts
- SoundService
- KeyframeSequenceProvider
- VRService
- PluginGuiService
- Player
- Teams
- Pose
- Keyframe
- KeyframeSequence
- IntConstrainedValue
- DoubleConstrainedValue
- ForceField
- RayValue
- Fire
- Smoke
- Sparkles
- ParticleEmitter
- IntValue
- StringValue
- NumberValue
- Explosion
- ObjectValue
- SoundGroup
- UserGameSettings
- ClickDetector
- Sound
- Selection
- BadgeService
- TaskScheduler
- GlobalDataStore
- DataStoreService
- CustomEvent
- CustomEventReceiver
- VirtualInputManager
- FunctionalTest
- TweenBase
- SoundEffect
- ReflectionMetadataEvents
- ClusterPacketCache
- PVInstance
- FaceInstance
- Controller
- ReflectionMetadataCallbacks
- ReflectionMetadataFunctions
- ReflectionMetadataYieldFunctions
- ReflectionMetadataProperties
- ReflectionMetadata
- AdvancedDragger
- HapticService
- FriendService
- GamepadService
No Result Found !!!
GetFocusedTextBox
This function returns the TextBox
the client is currently focused on. A TextBox can be manually selected by the user, or selection can be forced using the TextBox/CaptureFocus
function. If no TextBox is selected, this function will return nil.
As UserInputService
is client-side only, this function can only be used in a LocalScript
.
See also
UserInputService/TextBoxFocused
UserInputService/TextBoxFocusReleased
TextBox/CaptureFocus
TextBox/IsFocused
TextBox/ReleaseFocus
Returns
Return Type | Summary |
---|---|
The |
Code Samples
Ignore User Input When a TextBox Is Focused
This example demonstrates how to ignore user input when any TextBox
is focused. When a player is not focusing on any TextBox, pressing the jumpKey (Enum/KeyCode|J Key
) change’s their humanoid’s Enum/HumanoidStateType|state
to Jumping using the Humanoid/ChangeState
function to make their character jump.
When the player is focusing on any TextBox, the player will not jump. The example checks if any TextBox is focused by checking if the UserInputService/GetFocusedTextbox
function returns nil
instead of a TextBox instance.
This connects to the Humanoid/StateChanged
event to determine when the player is jumping and prevent the player from using the jumpKey to jump while already jumping.
local UserInputService = game:GetService("UserInputService") local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character local humanoid = character:WaitForChild("Humanoid") local jumpKey = Enum.KeyCode.J local isJumping = false local function InputBegan(input, gameProcessedEvent) local TextBoxFocused = UserInputService:GetFocusedTextBox() -- Ignore input event if player is focusing on a TextBox if TextBoxFocused then return end -- Make player jump when user presses jumpKey Key on Keyboard if (input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == jumpKey) then if not isJumping then isJumping = true humanoid:ChangeState(Enum.HumanoidStateType.Jumping) end end end local function StateChanged(oldState, newState) -- Prevent player from jumping again using jumpKey if already jumping if (newState == Enum.HumanoidStateType.Jumping) then isJumping = true -- Allow player to jump again after landing elseif (newState == Enum.HumanoidStateType.Landed) then isJumping = false end end UserInputService.InputBegan:Connect(InputBegan) humanoid.StateChanged:Connect(StateChanged)
How this site use cookies
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.