PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetLastInputType

This function returns 'Enum/UserInputType` associated with the user’s most recent input.

For example, if the user’s previous input had been pressing the spacebar, the Enum/UserInputType returned would be ‘Keyboard’.

The UserInputService/LastInputTypeChanged event can be used to track when the last Enum/UserInputType used by the user changes.

As UserInputService is client-side only, this function can only be used in a LocalScript.

Returns

Return Type Summary

The Enum/UserInputType associated with the user’s most recent input


Code Samples


UserInputService:GetLastInputType

This example gets the Enum/UserInputType|last input type and indicates if it was keyboard input.

local UserInputService = game:GetService("UserInputService")

local lastInput = UserInputService:GetLastInputType()

if (lastInput == Enum.UserInputType.Keyboard) then
	print("Most recent input was via keyboard")
end