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

GetLastInputType

The GetLastInputType function indicates the most recent 'Enum/UserInputType` used by the client. The function’s return is the UserInputType last used by the client.

For instance, if, at the time this function is called, the client’s last interaction with the game is pressing the spacebar, the UserInputType returned would be UserInputType.Keyboard, since the spacebar is the keyboard’s button.

If you want to track when the last input type used by the client changes, you can use the UserInputService/LastInputTypeChanged event.

Since UserInputService only runs client-side, this function will only work when used in a LocalScript.

Returns

Return Type Summary

An Enum indicating the last UserInputType used by the client.


Code Samples


UserInputService:GetLastInputType

This example gets and prints the name of the last UserInputType used by the client.

local UserInputService = game:GetService("UserInputService")

local lastInput = UserInputService:GetLastInputType()
print(lastInput.Name)