vimium
vimium copied to clipboard
Map key to send arrow key keycode
I would like to map a key to send an arrow keypress to a webpage.
Example:
map D <right>
Use case:
http://www.mangatown.com/manga/working/v07/c173/4.html
Pressing the right arrow key navigates to page 5.html. I believe due to the code below. A little digging and I found keycode 39 is for the right arrow key but I do not know how to get vimium to send it to the site. Since the site is not using the links for goNext, ]] doesn't work.
KeyListener.addListener(39,next_page);KeyListener.addListener(37,previous_page);$(function(){var iw=$("#image").width();var it=$("#image").offset().top-81;$(".ad160_r").css({marginLeft:iw/2+ 5,top:it,left:"50%"});$(".ad160_l").css({marginRight:iw/2+ 5,top:it,right:"50%"});});var is_login='';var is_admin=false;
Thank you for your time and consideration.
Yeah, I as well, would like to know if something like this is possible. In my case I would love to bind <m-j> to <m-+> (zoomIn) <m-k> to <m--> (zoomOut)
but I do not know how to get vimium to send it to the site.
Vimium does not send keys to pages. I think you're asking for Vimium to remap a page's native bindings, which is not something Vimium does.
+1 for this. Some website keybindings conflict with mine (e.g. Github's t, and it would be great to map them specifically for that website (or globally), e.g. map T t)
+1 I have a use case very similar to @DrPhibes71
FWIW: Vimium-C has a feature to "Pass next keys" to webpage. It handled my use case.
Thanks! I'll check it out
FWIW: Vimium-C has a feature to "Pass next keys" to webpage. It handled my use case.
I'm not exactly sure what the functionality of that feature in Vimium-C is, but Vimium also has the passNextKey command that can be mapped to a key of your choice, which will send the very next keypress to the page instead of Vimium consuming it and then it turns back to Vimium acting as normal.
If you frequently need to use several keybindings of a page that would conflict with Vimium's bindings, you might want to use insert mode in those cases instead. That'll also basically "disable" Vimium temporarily until you exit insert mode again with Esc. One of the downsides of this is, that Vimium will also exit insert mode automatically, when you focus a textarea or text input.
Edit: Also if code-IM-perfect actually has the same / similar use-case as the OP, then passing keys is not what they're looking for. The OP seems to be looking for a way to remap a page's functionality using Vimium - and as smblott already said: That's not what Vimium does.
That is correct.
So I expect j and k to behave as the up and down arrow keys and h and l to behave as left and right arrow keys. In reality however vimium seems to programmatically scroll the page instead of simply passing down the key event, letting the browser handle the scrolling.
My use-case is the rust book. On the rust book website, right arrow has a binding to move to the next section and the left arrow to the previous section, which forces me to use the arrow keys which in my opinion is breaking the vim experience.
From what I've seen it's not even possible for a webextension to simply "send keyevents" as that would open up a massive load of security vulnerabilities. So what you're asking for - pressing one key that's handled by a webextension which then triggers a new synthetic keypress which is sent to the page - isn't even possible in a generic way.
For websites that you visit really frequently, you might want to consider implementing a tailored solution for that very website, which can be done with a simple userscript through tampermonkey and similar addons.
The way to do it would be to create a keyhandler that handles the key presses you want and then select the DOM elements that normally trigger the function you want to achieve on click and invoke those HTMLElement's .click() function.
In most cases this is a quick and easy way to achieve such custom behavior on any website you want.
Hmm that makes sense, it would broaden the attack surface significantly. I'll try the tapermonkey way in that case, thanks!