GithubHelp home page GithubHelp logo

keyboard-lock's People

Contributors

autokagami avatar foolip avatar garykac avatar jamiewalch avatar joedow-42 avatar marcoscaceres avatar martinthomson avatar nschonni avatar tomayac avatar travisleithead avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyboard-lock's Issues

The second parallel request should be rejected

From @Hzj-jie on April 17, 2017 18:31

If we would prefer to return Promise from requestSystemKeyboardLock() function, once a web page requests twice in parallel, the second one should be rejected immediately. E.g.

function f() {
  const p1 = navigator.requestSystemKeyboardLock(['a', 'b']);
  const p2 = navigator.requestSystemKeyboardLock(['c', 'd']);

  p2.then(() => {
    assert_not_reachable();
  }).catch((e) => {
    // e should be a predefined DOMException.
  });
}

Copied from original issue: garykac/system-keyboard-lock#18

Using keyCode with a DOMString is confusing

I can't wrap my head around whether this is meant to be a keyCode as in in the UIEvent spec but those are unsigned int or a key which are also DOMString but do not seem to represent modifiers.

A guess this issue is too fold:

  • Is it keyCode or key? (or something else?)
  • How to register "Ctrl+C"? Maybe this could be clarified with an example or two in the specification.

Migration to WebApps WG: Implementor interest?

This specification has been proposed for migration to the WebApps WG (which is expected to partly replace the WebPlat WG). For this to happen, we need expressions of interest/intent to commit from at least two implementors.

Please let us know if you plan to implement this specification, or if you can point to any publicly documented expressions of interest from implementors.

The draft WebApps charter will go to the Advisory Committee (AC) within the next two or three weeks, so quick responses may make the difference.

@chaals @marcoscaceres

Reject acquisition of SKL when not in fullscreen (rather than silently not working)

From @mgiuca on March 23, 2017 2:0

The spec currently proposes that requestSystemKeyboardLock always succeed (in fact it does not define any possibility of failure; see #7). If not in full-screen, it is supposed to succeed but do nothing until fullscreen is entered.

Rather, it should reject if called when not in full-screen. When the enable keyboard lock flag is set, keyboard lock should work (and there should be no clause in "Handling Keyboard Events" that checks if full-screen).

Similarly, enable keyboard lock should be cleared when exiting full-screen.

Copied from original issue: garykac/system-keyboard-lock#9

Web page may receive out of order key events

From @Hzj-jie on March 31, 2017 21:6

@dtapuska mentioned this good question.
Once a web page requests some keys, according to #9, these keys should not be processed by browser. The behavior may introduce the out of order key events. E.g.

  • Web page requests "W" key.
  • User types "Q" and "W" in sequence.
  • "Q" is consumed or delayed by browser processing logic, maybe IME.
  • Web page receives "W" then "Q", or "W" only.

I do not think this could be a big deal. If the web page needs both "Q" and "W", it should request both keys. Otherwise, relying on "Q" is not a reasonable behavior. But we may explicitly call out this issue in the spec.

Copied from original issue: garykac/system-keyboard-lock#15

Still active?

Just checking in if this incubation is still active or if we should consider archiving?

low-level keyboard event handler

From @domenic on November 22, 2016 18:25

This term should probably be defined somewhere separate from the algorithm that registers it. Then it can get the proper treatment it deserves in terms of what normative effects it has, the interesting notes nearby, and so on.

It should explain what normative effect it has in as much detail as possible, although understandably this is kind of difficult. Currently it says "process keyboard events". Maybe expand on this a bit, i.e. something like "ensure that KeyboardEvent events are fired instead of performing the usual action of the system keyboard shortcut".

Also, it would be best to not use "event handler" since that has a specific meaning. Maybe "keyboard trap" or similar would be better.

Also, consistently use low-level or low level. I think with a hyphen is a bit better?

Copied from original issue: garykac/system-keyboard-lock#2

Links to http://www.w3.org/TR/systemkeylock/ and https://github.com/w3c/systemkeylock/ are 404

From @foolip on April 17, 2017 8:8

They're linked from the top of https://garykac.github.io/system-keyboard-lock/

Relatedly, please pick a single "shortname" and use it everywhere. In https://codereview.chromium.org/2805763004 tests are being added under keyboard-lock/ in web-platform-tests. Bikeshed: I prefer that to the longer system-keyboard-lock.

Copied from original issue: garykac/system-keyboard-lock#17

Escape/Esc key locking

I'm very uncomfortable with this API locking the [esc] key.

I can see that Special Considerations with the Escape Key have been made (ref issue 45), where:

...the user agent shows a user message "Press ESC to exit fullscreen" when
Javascript-initiated fullscreen is activated, then that message will need to
be updated when keyboard lock is in effect to read "Press and hold ESC 
to exit fullscreen".

I highly doubt users will read/notice a standard message that will typically disappear within a few seconds... but there is still a chance that users will press the [esc] key to escape from whatever full-screen thing they have fallen in to (I doubt many will continue to hold for 2 seconds).

Personally I want the Escape key to be excluded from this feature... I believe it should always Escape the view the user is currently in.

Update lock( ) example (section 2.2.1) to account for deferred system key press handler creation

The example in this section shows the promise returned by lock( ) as pending until the System key press handler is created and activated.

As I've been implementing this feature I've found one problem with this assumption which is that we don't expect the javascript caller to request keyboard lock more than once because the user agent will apply/remove the lock as appropriate, however there isn't a way to indicate when keyboard lock is active/inactive after the first lock event. An example where this doesn't work is where the UI loses and receives focus while in fullscreen. In that case the hook will be removed and recreated (some OSes like Linux do not allow for a hook to 'pass-through' key events, you receive the keys you request and cannot pass them down the handler chain) but the user agent cannot communicate these states to javascript.

I think the promise should resolve if the user agent is able to register the request (i.e. the method was called correctly and the request has been registered such that the hook will be activated when the UI is in the appropriate state).

Cases where requestKeyboardLock() should reject?

#34 is once case this could happen - another case would be in a platform/configuration/user preference where either it is undesirable to do so (as noted in the mobile platform bit on the spec) or the user rejects the lock. (either by an ephemeral preference or as a persistent preference, given that the implementation provides such a feature)

Account for Pointer Lock

Applications like ours bring full video games into the web browser. As such certain games require users to lock the mouse to the page to pass relative mouse movement (FPS games are the primary example).

Pressing ESC will cause Pointer Lock to end and then the user needs to retype the keystroke to relock the mouse. I haven't seen any discussion on this in the spec so I figured I'd bring up the use case. Ensuring the user can press ESC and pass the input to the game while in fullscreen while preserving the pointer lock is important.

2.1.2.1 algorithm should be explicit

"Copy the values from keyCodes into reserved key codes, removing any entries which are not valid KeyboardEvent codes or duplicate." is a bit too vague. Maybe it would be worth having a clear algorithm such as:

- Let keyList be a set of keyCode.
- For each value of keyCodes, if it is a valid KeyboardEvent code and is not already in keyList, insert it into keyList.
- Copy keyList into reserved key codes.

Clarify the usage in Example2 under the lock( ) call in section 2.2.1

The example here shows javascript requesting 'KeyW' and all W key combinations being sent to the website, however this is only true on qwerty keyboards. The example does call out that it is using codes but it is probably worth some clarification on what would happen for azerty keyboards here (and what to do about it).

Spec seems to describe an implementation

From @dtapuska on March 29, 2017 14:4

When reading:
https://garykac.github.io/system-keyboard-lock/#key-press-handler

It seems that the "system key press handler" is describing an implementation. An alternate implementation is that you could just have a table and know that the registered document/navigator has priority over executing the UA default action for these events.

It isn't clear to me that you need to hook the system listeners in order to implement this.

Copied from original issue: garykac/system-keyboard-lock#13

Navigator.requestSystemKeyboardLock() may return Promise<void> instead of void

From @Hzj-jie on March 19, 2017 23:40

Considering this is an extremely powerful API, which allows webpage to intercept any keys. Some browser vendors may implement a user notification or prompt to decide whether these APIs should be allowed or now. Meanwhile, web page may need a signal to indicate when the reserved keys are available, or whether the user declined the request. So it may fall back to use alternative keys.
So I suggest to change
void Navigator.requestSystemKeyboardLock()
into
Promise<void> Navigator.requestSystemKeyboardLock()

Once the Promise resolves, the web page should be able to retrieve the keys it requested.
The Promise will reject only if the user actively disallowed the API.
Due to the "best effort" principle of these APIs, no matter whether the keys or key combinations can be successfully retrieved, e.g. ctrl+alt+del is never cancelable on Windows, the Promise always resolves, once users or browser allowed the API.

void Navigator.cancelSystemKeyboardLock()
is not impacted by this change.

Copied from original issue: garykac/system-keyboard-lock#7

Where should enableKeyboardLock and reservedKeyCodes be stored?

From @domenic on November 22, 2016 18:22

One big issue to figure it is where the enableKeyboardLock and reservedKeyCodes are meant to be stored. They're certainly not stored in "the user agent", as that would mean that they are the same across all web sites. I see a few choices:

  • The browsing context (~ a "tab" in your browser). This seems unlikely, as it would mean they persist across navigation within that browsing context (even to cross-origin sites).
  • Every Window/environment settings object (they are 1:1). This would mean that if you inject code into about:blank and then navigate, the keyboard lock would be preserved (the Window is reused so all its values remain). But if you do document.open(), the keyboard lock would be lost (the Window is re-created).
  • Every Document that has a browsing context. (The latter clause is important so that document.implement.createDocument() or XHR responseDocument do not get this ability.) This would mean that navigating from about:blank to a new document loses keyboard lock, but doing document.open() does not.

So probably either Window or Document. I don't see a real reason to prefer one over the other; maybe Document is most conventional.

Once you've figured that out, it's important to say how to get to that variable inside your algorithms. So, let's say it was Window. Then step 1 of requestSystemKeyboardLock would be:

  1. Reset this Navigator object's relevant global object's reservedKeyCodes to be an empty sequence.

If it was the Document, it would be

  1. Reset this Navigator object's relevant global object's associated Document's reservedKeyCodes to be an empty sequence.

Similarly for references to enableKeyboardLock and so on.

Copied from original issue: garykac/system-keyboard-lock#1

Defining terms in "handling keyboard events" better

From @domenic on November 22, 2016 18:35

The isFullscreen check should check if a specific document's fullscreen element is non-null, instead of the current vague phrasing + implementation suggestion.

I'm not sure what "input focus" is, but if it's the same thing as normal focus, then it should check if a specific document's fullscreen element is the currently focused area of a top-level browsing context

In general this algorithm should probably either get moved into or replace https://html.spec.whatwg.org/#fire-a-focus-event. It seems like they are both trying to do the same thing. The HTML version has some more precise wording, but is of course missing the fullscreen and system keyboard lock stuff. I'd suggest copying as much from HTML as looks correct then adding your system keyboard lock stuff as you've done, with the tweaks above. We can eventually either move it back into HTML or have HTML link to this.

Copied from original issue: garykac/system-keyboard-lock#3

Editorial nits

From @domenic on November 22, 2016 18:37

  • Missing closing parens in "(which would capture all keys if enableKeyboardLock was enabled."
  • Is reservedKeyCodes a sequence or list? Either seems fine, but pick one and stick with it.

Copied from original issue: garykac/system-keyboard-lock#5

Add keyboard object on navigator and put this API there

Because there are other proposed APIs that would make use of a keyboard object, it makes sense to move these methods there instead of dumping them directly in navigator.

This was one of the ways proposed in the TAG review

navigator.keyboard.lock()
navigator.keyboard.unlock()

Mark as CG-DRAFT, move to WICG?

As this spec was not yet adopted by any WG, should it be moved to the WICG? If so, it should probably use the CG-DRAFT status, not "ED".

Cross-thread "reserved key codes" is problematic

You need to queue a task to update this. Currently the way you've written things the "in parallel" thread could update it, then hang for seconds, then add another key, etc. That wouldn't give very deterministic behavior.

Monkeypatching UI Events is problematic

You redefine how dispatching key events works. Please make sure that's tightly coupled with the relevant prose in UI Events (it might be that such prose there is still lacking, I recommend encouraging the editors to finally add it if so). Otherwise we'll just end up with a giant mess and nobody being really sure in what order things actually happen.

What about mapped virtual keys?

From @dtapuska on March 29, 2017 14:18

Will anyone want actually mapped keys? Not specifically games or chromoting (where the keyboard layout is irrevlant to the webpage). But say someone wants to provide their own Ctrl-P (printing functionality). How do they know that on dvorak keyboard they need to actually register the 'R' in this API to get that functionality? But on a qwerty keyboard they use 'P'.

The fact that the page doesn't know the current keyboard layout and when the keyboard layout changes can be difficult to implement that functionality on top of this API. Perhaps these aren't cases we need to solve.

@smaug---- Probably someone from Gecko might have some feedback on this proposal.

Copied from original issue: garykac/system-keyboard-lock#14

Allow for low level mouse hooks

One thing I didn't come across while reading the proposal was the ability to capture the X buttons on the mouse. Mice these days have at least two X buttons, usually used to signal back or forward navigation in the browser.

They are indeed Virtual Key Codes, however I'm not sure if standard keyboard hooks detect them. They are posted the application as WM_XBUTTONDOWN and WM_XBUTTONUP.

Seeing as games can use them in more native environments, the ability to lock them for use in the browser would be useful.

Should trusted iFrames be allowed to request KeyboardLock

The fullscreen API includes a flag which can be applied to an iFrame which allows code executing in the iFrame context to request fullscreen. Spec: https://fullscreen.spec.whatwg.org/#iframe-fullscreen-flag

Is this something we would want to do as a future extension to the KeyboardLock spec?

The scenario would be a site that hosts a game in an iframe which has the ability to request fullscreen. The game code could also request the set of keyboardkeys it requires while in fullscreen mode. Otherwise the hosting site would have to request Keyboard lock on its behalf.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.