mirror of
https://github.com/A-Star100/simpliplay-xbox.git
synced 2025-09-17 22:39:39 +00:00
Create focus.js
This commit is contained in:
parent
b5fdd87dd4
commit
8cd926e0df
19
SimpliPlay UWP/WebAssets/focus.js
Normal file
19
SimpliPlay UWP/WebAssets/focus.js
Normal file
@ -0,0 +1,19 @@
|
||||
document.addEventListener("keydown", function(e) {
|
||||
if (e.key === "Enter") {
|
||||
const focused = document.activeElement;
|
||||
|
||||
if (focused) {
|
||||
// If focus is on a button, just click it
|
||||
if (focused.tagName === "BUTTON") {
|
||||
focused.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
// If focus is on a text input or checkbox, find the highlighted button and click it
|
||||
else if (focused.tagName === "INPUT") {
|
||||
// You can define which button to click here.
|
||||
// For example, the button with id="myButton"
|
||||
focused.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user