Hotkey bindings¶
window.host
getAllHotkeyBindings(ResultCallback<HotkeyBindingInfo[]>)¶
Available since API version 1.3
Get all OBS hotkey bindings.
Data structures: HotkeyBindingInfo
addHotkeyBinding(HotkeyBindingInfo, ResultCallback<boundHotkeyId>)¶
Available since API version 1.3
Add OBS hotkey binding. If the hotkey binding (identified by name property) exists, the call will fail and return null.
When determining the values for the triggers property, it is recommended to subscribe to the hostContainerKeyCombinationPressed event.
This event exposes the KeyCombinationInfo corresponding to the key combination which is currently being pressed.
The KeyCombinationInfo.description property indicates the human-readable description of the key combination as it is generated by OBS hotkey APIs.
Example (capturing key combinations):
<div id="divInputContainer"></div>
<script>
(function() {
var container = document.getElementById("divInputContainer");
function addField(labelContent) {
var div = document.createElement("div");
var label = document.createElement("label");
var input = document.createElement("input");
label.innerHTML = labelContent;
input.type = "text";
input.setAttribute("readonly", "true");
div.appendChild(label);
div.appendChild(input);
container.appendChild(div);
(function() {
// Capture 'input'
function handleKeyCombination(e) {
input._lastKeyCombination = e.detail;
input.value = e.detail.description;
}
input.addEventListener('focus', function(e) {
window.addEventListener(
"hostContainerKeyCombinationPressed",
handleKeyCombination);
input.style.border = "2px solid blue";
});
input.addEventListener('blur', function(e) {
window.removeEventListener(
"hostContainerKeyCombinationPressed",
handleKeyCombination);
input.style.border = "1px solid black";
});
})();
}
addField("Field 1");
addField("Field 2");
addField("Field 3");
})();
</script>
Example (binding hotkeys):
var bindingByKeyName = {
name: "Test.1",
description: "Test hotkey",
eventDetail: { dataKey: "dataValue" },
triggers: [
{ keyName: "OBS_KEY_T", ctrlKey: true, altKey: true }
]
};
var bindingByVirtualKeyCode = {
name: "Test.1",
description: "Test hotkey",
eventDetail: { dataKey: "dataValue" },
triggers: [
{ virtualKeyCode: 13, ctrlKey: true, altKey: true }
]
};
window.host.addHotkeyBinding(bindingByKeyName, function(boundHotkeyId) {});
window.host.addHotkeyBinding(bindingByVirtualKeyCode, function(boundHotkeyId) {});
Data structures: HotkeyBindingInfo
removeHotkeyBindingById(hotkeyId, ResultCallback<success>)¶
Available since API version 1.3
Remove OBS hotkey binding by Id.
getAllManagedHotkeyBindings(ResultCallback<HotkeyBindingInfo[]>)¶
Available since API version 1.3
Get all OBS hotkey bindings managed by OBS.Live. This method can be used to store hotkey bindings in the cloud for later retrieval and restoration by calls to addHotkeyBinding().
Data structures: HotkeyBindingInfo
setHotkeyBindingTriggers(Pick<HotkeyBindingInfo, ‘id’ | ‘triggers’>, ResultCallback<success>)¶
Available since API version 6.5
Replaces existing hotkey binding triggers with specified list of triggers.
Hotkey selection is done by hotkey id, which allows selecting any hotkey, including those defined by OBS itself.
Data structures: HotkeyBindingInfo