Skip to main content

InputKeyMapList

An input key map list provides a mapping of input modes to input keys. One of these should generally exist per an action with unique bindings.

All inputs should be bound while this action is active. We can further query inputs per an input mode to display only relevant key bindings to the user.

local inputKeyMapList = InputKeyMapList.new("BOOST", {
	InputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.LeftControl });
	InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX });
	InputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton("primary1") });
})

maid:GiveTask(Rx.combineLatest({
	isRobloxTouchButton = inputKeyMapList:ObserveIsRobloxTouchButton();
	inputEnumsList = inputKeyMapList:ObserveInputEnumsList();
}):Subscribe(function(state)
	maid._contextMaid = nil

	local contextMaid = Maid.new()

	ContextActionService:BindActionAtPriority(
		"MyAction",
		function(_actionName, userInputState, inputObject)
			print("Process input", inputObject)
		end,
		state.isRobloxTouchButton,
		Enum.ContextActionPriority.High.Value,
		unpack(state.inputEnumsList))

		maid._contextMaid = contextMaid
	end))
end))

Functions

new

InputKeyMapList.new(
inputMapNamestring,
inputKeyMapList{InputKeyMap},
options{
bindingNamestring,
rebindableboolean
}--

configuration options

) → InputKeyMapList

Constructs a new InputKeyMapList

fromInputKeys

InputKeyMapList.fromInputKeys(
inputKeys{any},
options{
bindingNamestring,
rebindableboolean
} | nil--

Optional configuration options

) → InputKeyMapList

Constructs a new InputKeyMapList from specific keys

local inputKeyMapList = InputKeyMapList.fromInputKeys({ Enum.KeyCode.E })

isInputKeyMapList

InputKeyMapList.isInputKeyMapList(valueany) → boolean

Returns whether this value is an InputKeyMapList

IsUserRebindable

InputKeyMapList:IsUserRebindable() → boolean

Returns user bindable time

GetBindingName

InputKeyMapList:GetBindingName() → string

Gets the english name

Add

InputKeyMapList:Add(inputKeyMapInputKeyMap) → ()

Adds an input key map into the actual list

GetListName

InputKeyMapList:GetListName() → string

Gets the list name and returns it. Used by an input key map provider

ObservePairsBrio

InputKeyMapList:ObservePairsBrio() → Observable<Brio<InputModeType,InputKeyMap>>

Observes a brio with the first value as the InputModeType and the second value as the KeyMapList

RestoreDefault

InputKeyMapList:RestoreDefault() → ()

Restores the default value for all lists

RemoveInputModeType

InputKeyMapList:RemoveInputModeType(inputModeTypeInputModeType) → ()

Removes the entry for the inputmodeType

ObserveInputKeyMapsBrio

InputKeyMapList:ObserveInputKeyMapsBrio() → Observable<Brio<InputKeyMap>>

ObserveInputModesTypesBrio

InputKeyMapList:ObserveInputModesTypesBrio() → Observable<Brio<InputModeType>>

ObserveInputKeyMapForInputMode

InputKeyMapList:ObserveInputKeyMapForInputMode(inputModeTypeInputModeType) → Observable<InputKeyMap>

Observes the input types for the active input map

ObserveIsTapInWorld

InputKeyMapList:ObserveIsTapInWorld() → Observable<boolean>

Observes whether the input list includes tapping in the world somewhere.

ObserveIsRobloxTouchButton

InputKeyMapList:ObserveIsRobloxTouchButton() → Observable<boolean>

Observes whether the input list includes a Roblox button.

IsRobloxTouchButton

InputKeyMapList:IsRobloxTouchButton() → boolean

Gets whether the input list includes a Roblox button.

IsTouchTapInWorld

InputKeyMapList:IsTouchTapInWorld() → boolean

Gets whether the input list includes a Roblox button.

ObserveInputEnumsList

InputKeyMapList:ObserveInputEnumsList() → Observable<{UserInputType | KeyCode}>

Observes the input enums list, which can be used for bindings.

ObserveInputEnumsSet

InputKeyMapList:ObserveInputEnumsSet() → Observable<{[UserInputType | KeyCode]true}>

Observes the input enums set

ObserveSlottedTouchButtonDataBrio

InputKeyMapList:ObserveSlottedTouchButtonDataBrio() → Observable<SlottedTouchButton>

Observes slotted touch button data in the input modes.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new InputKeyMapList",
            "params": [
                {
                    "name": "inputMapName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "inputKeyMapList",
                    "desc": "",
                    "lua_type": "{ InputKeyMap }"
                },
                {
                    "name": "options",
                    "desc": "configuration options",
                    "lua_type": "{ bindingName: string, rebindable: boolean }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InputKeyMapList"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "fromInputKeys",
            "desc": "Constructs a new InputKeyMapList from specific keys\n\n```\nlocal inputKeyMapList = InputKeyMapList.fromInputKeys({ Enum.KeyCode.E })\n```",
            "params": [
                {
                    "name": "inputKeys",
                    "desc": "",
                    "lua_type": "{ any }"
                },
                {
                    "name": "options",
                    "desc": "Optional configuration options",
                    "lua_type": "{ bindingName: string, rebindable: boolean } | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InputKeyMapList"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 99,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "isInputKeyMapList",
            "desc": "Returns whether this value is an InputKeyMapList",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 134,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "IsUserRebindable",
            "desc": "Returns user bindable time",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 142,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "GetBindingName",
            "desc": "Gets the english name",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 150,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "Add",
            "desc": "Adds an input key map into the actual list",
            "params": [
                {
                    "name": "inputKeyMap",
                    "desc": "",
                    "lua_type": "InputKeyMap"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 162,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "GetListName",
            "desc": "Gets the list name and returns it. Used by an input key map provider",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 173,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObservePairsBrio",
            "desc": "Observes a brio with the first value as the InputModeType and the second value as the KeyMapList",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<InputModeType, InputKeyMap>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 233,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "RestoreDefault",
            "desc": "Restores the default value for all lists",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 240,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "RemoveInputModeType",
            "desc": "Removes the entry for the inputmodeType",
            "params": [
                {
                    "name": "inputModeType",
                    "desc": "",
                    "lua_type": "InputModeType"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 251,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveInputKeyMapsBrio",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<InputKeyMap>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 260,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveInputModesTypesBrio",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<InputModeType>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 267,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveInputKeyMapForInputMode",
            "desc": "Observes the input types for the active input map",
            "params": [
                {
                    "name": "inputModeType",
                    "desc": "",
                    "lua_type": "InputModeType"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<InputKeyMap>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 277,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveIsTapInWorld",
            "desc": "Observes whether the input list includes tapping in the world somewhere.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 288,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveIsRobloxTouchButton",
            "desc": "Observes whether the input list includes a Roblox button.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<boolean>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 299,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "IsRobloxTouchButton",
            "desc": "Gets whether the input list includes a Roblox button.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 310,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "IsTouchTapInWorld",
            "desc": "Gets whether the input list includes a Roblox button.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 321,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveInputEnumsList",
            "desc": "Observes the input enums list, which can be used for bindings.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<{UserInputType | KeyCode}>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 332,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveInputEnumsSet",
            "desc": "Observes the input enums set",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<{[UserInputType | KeyCode]: true }>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 343,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        },
        {
            "name": "ObserveSlottedTouchButtonDataBrio",
            "desc": "Observes slotted touch button data in the input modes.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<SlottedTouchButton>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 354,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "InputKeyMapList",
    "desc": "An input key map list provides a mapping of input modes to input keys.\nOne of these should generally exist per an action with unique bindings.\n\nAll inputs should be bound while this action is active. We can further\nquery inputs per an input mode to display only relevant key bindings to\nthe user.\n\n```lua\nlocal inputKeyMapList = InputKeyMapList.new(\"BOOST\", {\n\tInputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.LeftControl });\n\tInputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX });\n\tInputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton(\"primary1\") });\n})\n\nmaid:GiveTask(Rx.combineLatest({\n\tisRobloxTouchButton = inputKeyMapList:ObserveIsRobloxTouchButton();\n\tinputEnumsList = inputKeyMapList:ObserveInputEnumsList();\n}):Subscribe(function(state)\n\tmaid._contextMaid = nil\n\n\tlocal contextMaid = Maid.new()\n\n\tContextActionService:BindActionAtPriority(\n\t\t\"MyAction\",\n\t\tfunction(_actionName, userInputState, inputObject)\n\t\t\tprint(\"Process input\", inputObject)\n\t\tend,\n\t\tstate.isRobloxTouchButton,\n\t\tEnum.ContextActionPriority.High.Value,\n\t\tunpack(state.inputEnumsList))\n\n\t\tmaid._contextMaid = contextMaid\n\tend))\nend))\n```",
    "source": {
        "line": 40,
        "path": "src/inputkeymaputils/src/Shared/InputKeyMapList.lua"
    }
}