h5player icon indicating copy to clipboard operation
h5player copied to clipboard

[BUG] key up/down doesn't scroll window as spected

Open fclotet opened this issue 3 years ago • 4 comments

  1. Problem Description Key up/down doesn't scroll window as expected, the script doesn't take in count the context (selected or not the video) or if there is or not a video in page. Even, normal keys are being override: for example alt+d, ctrl+c, ctrl+f

  2. Address where the above problem occurred Examples wrong working: https://www.google.com/search?q=mosnters+&sxsrf=AOaemvJo1l88eooHrrwxQUKV1qSKqgKZYw%3A1631058981816&source=hp&ei=Jfw3YYzYLtLH5OUPxsajoAo&iflsig=ALs-wAMAAAAAYTgKNec74PdRYuSTyqupFivVN_50Y1om&oq=mosnters&gs_lcp=Cgdnd3Mtd2l6EAMyCgguEAoQywEQkwIyBwguEAoQywEyBwgAEAoQywEyBwgAEAoQywEyBwguEAoQywEyBAgAEAoyBAgAEAoyBAgAEAoyBAguEAoyBAgAEAo6BAgjECc6BQgAEJECOgsILhCABBDHARDRAzoFCAAQgAQ6BQguEIAEOgQIABBDOgsILhCABBDHARCjAjoLCC4QgAQQxwEQrwE6BwgAEIAEEApQqhdYhx9goihoAHAAeACAAa8BiAHzB5IBAzIuNpgBAKABAQ&sclient=gws-wiz&ved=0ahUKEwjM_tyZiO7yAhXSI7kGHUbjCKQQ4dUDCAc&uact=5 https://www.youtube.com/ Even with "caret browsing" scroll stops working (https://support.google.com/chrome/answer/10129654?hl=en)

  3. Information about the browser and browser version you are using Google Chrome V92.0.4515.159 (Build oficial) (64 bits) ScriptVersion: 3.3.9

  4. Other additional information I was using the extension before and i think is amaizing some thigs like changing velocity, picture in picture, and others... but is really disturbing how the script overwride the standards keys. My original language is Spanish, but my browser is in English.

Regards, Fidel

fclotet avatar Sep 08 '21 00:09 fclotet

In my local i have added the present code... I do a "valvule" that is opened/closed with the key ctrl+alt+z.

When te valvule is opened the key interpretation for h5Player continue, if it is closed h5Player hotKeys are ignored.

The code added is the yellow one... 2021-09-08 10_51_17-sugerenciaValvula

... continueKeyInterpeter: function (event, key) { const t = h5Player; if (!event.shiftKey && event.ctrlKey && event.altKey && !event.metaKey && key === 'z') { t.h5PlayerValvule = !!!t.h5PlayerValvule; debug.log(continueKeyInterpeter:h5 Valvule now is ${t.h5PlayerValvule? 'opened': 'closed'}); event.stopPropagation(); event.preventDefault(); return false; } return !!t.h5PlayerValvule; }, ... palyerTrigger: function (player, event) { ... const key = event.key.toLowerCase(); if (!t.continueKeyInterpeter(event, key)) { return; }; ...

fclotet avatar Sep 08 '21 14:09 fclotet

Some of this may be a bug, but other things are design decisions or misunderstandings. Let's try to figure out which is which and how to improve. (And by the way, I'm not maintainer here, just trying to sort out problems overall.)

Let me first say that I couldn't reproduce the "google search" problem. For me there is no video (only links) in the results and the script leaves up/down to the browser. Did you get a video tag in the results?

I have Chrome v94, could you try that? What is your script manager, I run TamperMonkey 4.13. Do you have any other plugins/scripts that might interfere with this one?

normal keys are being override: for example alt+d, ctrl+c, ctrl+f

I don't think any of those are in the script. Since you know coding, can you breakpoint in keydownEvent and palyerTrigger functions to find out what happens, e.g. for ctrl-c. Where would it call stopPropagation?

script doesn't take in count the context (selected or not the video)

The design decision is to default to "global mode", where you're right . Check t.globalMode in code. To toggle mode, use Ctrl-\ (however key code 220 doesn't exist on my keyboard, so you may find the same issue).

A workaround similar to what you suggested I think already exist if you search for t.enable. Toggle all input with Ctrl-space.

or if there is or not a video in page.

The intention is to only activate commands when there is a video detected. Could you help debug why that's not the case for you?

if (!player) { // debug.log('无可用的播放,不执行相关操作') return

Key up/down doesn't scroll window as expected

When all conditions are met, the design is to override up/down keys, that's true. If you don't want to toggle as mentioned above, you could (as a workaround for now) change the shortcut for volume in the code.

disturbing how the script overwride the standards keys.

I suppose the idea is to make the shortcuts as accessible as possible. It would be nice to have things more configurable though.

My original language is Spanish, but my browser is in English.

Keyboard layout is tricky, so if you find that unexpected shortcuts trigger, check http://keycode.info/ to see which key the browser actually thinks you press.

JAGulin avatar Sep 29 '21 21:09 JAGulin

@fclotet Did you get the opportunity to check my comments?

JAGulin avatar Oct 25 '21 06:10 JAGulin

Dear @JAGulin thanks for your collaboration and taking in count my observations.

I understood you are not a programmer but your intervention as a "functional" is in any way much important...

I only can say that now I am not having any problem with shortcuts, I am trying to reproduce the problems and I can't...

So I can't collaborate telling the origin of the problem, only I can say that it was a problem for me because I use a lot some shortcuts like X C shift+P but the way that it was blocking other standard keys was disturbing.

And yes... I understood that much of the way that is it working is part of design, or expected way of working.

I didn't know about globalMode, it's a good option... for example in default mode youtube home page (https://www.youtube.com/) up/down keys are not working but setting global off they works. (By the way, I don't have access to that key -220- so I should change to ctrl+i the code to test globalMode).

Sorry not answering in time, but I was on Holidays and I back with much things to do.

Thanks for paying attention, if I have any of the problems again I'll try to check more about debugging.

fclotet avatar Oct 26 '21 03:10 fclotet