InputObject

InputObject : Instance

Properties

Delta

Vector3

Delta is a property of type vector3 representing the change in position or movement primarily used to track touch movements.

Code Samples

local ContextActionService = game:GetService("ContextActionService")
local ActionName = "JumpAction"
local IsCreateTouchButton = true
local KeyCode = Enum.KeyCode.F

local function OnAction(actionName, inputState, inputObject)	
    if inputState == Enum.UserInputState.Change then
        print(inputObject.Delta)
    end
end
ContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)

KeyCode

Enum.KeyCode

KeyCode is a property of type Enum.KeyCode representing the specific key or button pressed during user input events.

Code Samples

local ContextActionService = game:GetService("ContextActionService")
local ActionName = "JumpAction"
local IsCreateTouchButton = true
local KeyCode = Enum.KeyCode.F

local function OnAction(actionName, inputState, inputObject)
end
ContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)

Position

Vector3

Position is a property representing the positional value or current location of an input event.

Code Samples

local ContextActionService = game:GetService("ContextActionService")
local ActionName = "JumpAction"
local IsCreateTouchButton = true
local KeyCode = Enum.KeyCode.F

local function OnAction(actionName, inputState, inputObject)	
    if inputState == Enum.UserInputState.Change then
        print(inputObject.Position)
    end
end
ContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)

UserInputState

Enum.UserInputState

UserInputState indicates the current state of an input being performed, which may include pressed, released, held, pending, or other distinct stages defined by the associated UserInputType.

Code Samples

local ContextActionService = game:GetService("ContextActionService")
local ActionName = "JumpAction"
local IsCreateTouchButton = true
local KeyCode = Enum.KeyCode.F

local function OnAction(actionName, inputState, inputObject)
    if inputState == Enum.UserInputState.Begin then
        print("Begin!")
        
    elseif inputState == Enum.UserInputState.Change then
        print("Change!")
        
    elseif inputState == Enum.UserInputState.End then
        print("End!")
        
    elseif inputState == Enum.UserInputState.Cancel then
        print("Cancel!")
    end
end
ContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)

UserInputType

Enum.UserInputType

UserInputType is an enumeration representing the type of user input, such as mouse, keyboard, gamepad, or touch.

Code Samples

local ContextActionService = game:GetService("ContextActionService")
local ActionName = "JumpAction"
local IsCreateTouchButton = true
local KeyCode = Enum.KeyCode.F

local function OnAction(actionName, inputState, inputObject)	
	if inputObject.UserInputType == Enum.UserInputType.Touch then
	    print("Touch!")
	end
    end
end
ContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)

Methods

Events

Last updated