Input
The 'Input' class provides an interface to gather information from various external inputs. 'Input' works like a monitoring station, keeping track of user actions and triggering responses within the game.
Each of these properties contain events that are fired when the corresponding action is performed, and game developers can add listeners to these events to trigger custom game logic.
Properties
The 'IsAltPressed' property indicates if the Alt key is currently being pressed on the keyboard. This can be useful for creating keyboard shortcuts or alternate modes within the game.
if Input.IsAltPressed then
-- Perform an action when the Alt key is pressed
end
The 'IsMouseInput' property helps to detect whether a mouse device is providing input. false == touch input
if Input.IsMouseInput then
-- Perform an action when the mouse is providing input
end
The 'PinchOrDragBegan' property listens for the beginning of pinch or drag gestures on a touch screen. Such gestures are common in mobile UI for operations like zooming or moving objects and can be leveraged effectively in game controls. See Class.PinchGestureBegan for more details on the parameter of the event.
Input.PinchOrDragBegan:Connect(function(pinchOrDrag)
-- Perform an action when a pinch or drag gesture begins
end)
The 'PinchOrDragChanged' property fires an event whenever there is a change in an ongoing pinch or drag gesture on the touch screen. This allows the game to continuously track such gestures and make corresponding adjustments in its state. See Class.PinchGestureChanged for more details on the parameter of the event.
Input.PinchOrDragChanged:Connect(function(pinchOrDrag)
-- Perform an action when a pinch or drag gesture changes
end)
The 'PinchOrDragEnded' property listens for the end of a pinch or drag gesture on a touch screen. This allows the game to know precisely when such a gesture ends and probably trigger appropriate actions thereafter. See Class.PinchGestureEnded for more details on the parameter of the event.
Input.PinchOrDragEnded:Connect(function(pinchOrDrag)
-- Perform an action when a pinch or drag gesture ends
end)
The 'MouseWheel' property listens for movements of the mouse wheel. This input allows interactions like zooming in or out or scrolling through menus, especially on platforms with a mouse device. See Class.MouseWheel for more details on the parameter of the event.
Input.MouseWheel:Connect(function(mouseWheel)
-- Perform an action when the mouse wheel moves
end)