GetKeysPressed

Constructor:

GetKeysPressed()

Description

Returns the InputObject array correlated with the current pressed enumerated key/code key

Return Value

Variable name Type Default Description
table {inputobject input_information_object_list}

Examples

Keep monitoring the enumerated keys pressed on the current object in the loop. Traverse the returned table and observe whether the traversal information is correct or not.

coroutine.start(function()
    while true do
        coroutine.wait(0.1)
        local str = ""
        local a = UserInputService.GetKeyPressed()
        for i = 1,#a do
            str = str..tostring(a[i].InputKeyCode).."  "
        end
        print(str)
    end
end)
-- Notes: The returned array is nil