Skip to content

Allow keyboard lock#3043

Merged
gantoine merged 7 commits intorommapp:masterfrom
matthewturk:keyboard_lock
Feb 28, 2026
Merged

Allow keyboard lock#3043
gantoine merged 7 commits intorommapp:masterfrom
matthewturk:keyboard_lock

Conversation

@matthewturk
Copy link
Copy Markdown
Contributor

Description

This adds a config option to enable keyboard lock for the EmulatorJS player. If the config option is set, it adds a listener for when fullscreen changes. When the element goes fullscreen, the keyboard is locked; among other things, this allows escape to be used as a normal keypress in dosbox_pure, although there may be other uses available as well. When the element ceases to be fullscreen, the keyboard is explicitly unlocked.

This lets games that use escape to function normally in fullscreen mode, and while I believe it may not be implemented in all browsers, I've put the functionality behind a conditional to check before attempting to execute it. By default the option is off. I've prepared a pull request for the documentation repository pending any changes/rejections here.

I did use Gemini as a sounding board for finding information about fullscreen mode, but every text character in this was written by me with no autocomplete or other copilot/AI enhancement.

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @matthewturk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the EmulatorJS player experience by providing a configurable option to lock the keyboard during fullscreen gameplay. This feature addresses issues where system-level keybindings (like the Escape key exiting fullscreen) can disrupt emulation, particularly for games that rely on these keys. By integrating this setting into both the backend and frontend, users gain more control over their gaming environment, ensuring a more immersive and uninterrupted experience within the emulator.

Highlights

  • New Configuration Option: Introduced a new configuration option, EJS_KEYBOARD_LOCK, which allows users to enable or disable keyboard locking for the EmulatorJS player. This option defaults to false.
  • Backend Integration: The backend has been updated to incorporate the EJS_KEYBOARD_LOCK setting, including its definition in the config class, parsing from the raw configuration, validation to ensure it's a boolean, and inclusion in the configuration file updates and API responses.
  • Frontend Keyboard Locking Logic: The frontend now implements logic to automatically lock the keyboard when the EmulatorJS player enters fullscreen mode and EJS_KEYBOARD_LOCK is enabled. It specifically locks common system keys like Escape, Tab, AltLeft, ControlLeft, and MetaLeft to prevent them from interfering with gameplay. The keyboard is unlocked when exiting fullscreen.
Changelog
  • backend/config/config_manager.py
    • Added EJS_KEYBOARD_LOCK property to the Config class.
    • Included EJS_KEYBOARD_LOCK in the _parse_config method with a default value of False.
    • Implemented validation for EJS_KEYBOARD_LOCK to ensure it is a boolean type.
    • Added keyboard_lock to the emulatorjs section when updating the config file.
  • backend/endpoints/configs.py
    • Included EJS_KEYBOARD_LOCK in the ConfigResponse returned by the get_config endpoint.
  • backend/endpoints/responses/config.py
    • Added EJS_KEYBOARD_LOCK as a boolean type to the ConfigResponse TypedDict.
  • backend/tests/config/fixtures/config/config.yml
    • Added keyboard_lock: true to the emulatorjs section for testing purposes.
  • backend/tests/config/test_config_loader.py
    • Added assertions to verify the correct loading of EJS_KEYBOARD_LOCK in test cases for both default and specified configurations.
  • examples/config.example.yml
    • Added a commented example for the keyboard_lock option with a description.
  • frontend/src/generated/models/ConfigResponse.ts
    • Added EJS_KEYBOARD_LOCK as a boolean type to the generated TypeScript ConfigResponse interface.
  • frontend/src/stores/config.ts
    • Added EJS_KEYBOARD_LOCK with a default value of false to the frontend's default configuration store.
  • frontend/src/views/Player/EmulatorJS/Base.vue
    • Destructured EJS_KEYBOARD_LOCK from the config store.
    • Implemented a fullscreenchange event listener that conditionally locks or unlocks the keyboard using the navigator.keyboard.lock() API based on the EJS_KEYBOARD_LOCK setting and fullscreen status, targeting specific system keys.
Activity
  • No activity provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new configuration option, EJS_KEYBOARD_LOCK, to allow locking the keyboard when the EmulatorJS player is in fullscreen mode. The changes span across the backend and frontend, including configuration management, API endpoints, tests, and the Vue player component. The implementation is solid, with updates to tests and documentation. I have one suggestion on the frontend to improve the event listener handling for better resource management.

@gantoine gantoine self-requested a review February 22, 2026 03:12
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Added keyboard lock API integration to enable escape key and other system keys to function as regular inputs when the EmulatorJS player is in fullscreen mode. The implementation listens for fullscreen changes and locks specific keys (Escape, Tab, AltLeft, ControlLeft, MetaLeft) when entering fullscreen, then unlocks them when exiting.

Key changes:

  • Imported useEventListener from @vueuse/core for automatic cleanup
  • Added TypeScript type declarations for the Keyboard Lock API
  • Implemented fullscreen change listener with proper error handling via .catch()
  • Feature is only activated when the browser supports the Keyboard Lock API (checked via "keyboard" in navigator)

Note: Despite the PR description mentioning a config option, the implementation applies keyboard lock universally when the API is available (commit dea63246 removed the config option). The PR description should be updated to reflect this change.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • Clean implementation with proper TypeScript typing, error handling via promise catch, browser compatibility checks, and automatic cleanup via VueUse. Previous review feedback has been thoroughly addressed.
  • No files require special attention

Important Files Changed

Filename Overview
frontend/src/views/Player/EmulatorJS/Base.vue Added keyboard lock functionality on fullscreen with proper TypeScript types, error handling, and VueUse event listener

Last reviewed commit: d00b762

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

@gantoine gantoine merged commit c0f666e into rommapp:master Feb 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants