local ContextActionService = game:GetService("ContextActionService")
local function OpenTextBox(ActionName, InputState, InputObject)
print(InputObject.KeyCode)
end
ContextActionService:BindAction("OpenTextBox", OpenTextBox, false, Enum.KeyCode.A, Enum.KeyCode.O, Enum.KeyCode.K)
Press keys A, O, and K
Expected Behavior
All keys might be recognized.
Actual Behavior
Enum.KeyCode.O is not being recognized
Issue Area: Engine Issue Type: Other Impact: High Frequency: Constantly
Unfortunately, by default, keys âIâ and âOâ are both used for Roblox core features for zooming the playerâs camera in and out. You are going to have to either use different keys, or you can suggest the following solution:
local UserInputService = game:GetService("UserInputService")
local keyOHeld = UserInputService:IsKeyDown(Enum.KeyCode.O) // Returns a boolean value of true or false
For anyone that wants to do that, it is here. But be warned, this will also disable the left and right arrow keys. If you wish to keep the left/right arrow keys and unbind I and O, you can put this in your StarterPlayerScripts: PlayerModule.rbxm (114.8 KB)
Itâs just the default player module with I and O removed.
You can use BindActionAtPriority with a very high priority to override the existing built-in keybind, however, you should refrain from overriding default keybinds since it may be confusing to users.
Iâd recommend always using BindActionAtPriority over BindAction.
local ContextActionService = game:GetService("ContextActionService")
local function OpenTextBox(ActionName, InputState, InputObject)
print(InputState, InputObject.KeyCode)
end
game:GetService("ContextActionService"):BindActionAtPriority("Test", OpenTextBox,
false, 3000,
Enum.KeyCode.I, Enum.KeyCode.O, Enum.KeyCode.K)
But for some reason, only Enum.UserInputState.End is being intercepted for keys I and OâŚ
If you are testing this in Studio, make sure âRespect Studio shortcutsâ in settings > Studio is disabled. I think O/I might also be normal Studio shortcuts in addition to being in-game shortcuts.