The problem is that when I press the left arrow key it seems to generate two "CTRL + PGUP" which results in two steps in the tab list, not one as I would expect. Same problem for the right arrow.
Am I doing something wrong here?
/ermhawi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are actually 3 possible states for any standard keyboard event, where Event.Value signifies the state:
- Event.Value == 0 means the button has been release
- Event.Value == 1 means the button has been pressed
- Event.Value == 2 means the button has been repeated (pressed and held)
So I think all you should need to do is (where ____ is a tab):
Hi, I have tried to extend this a bit further and I have come to realize that this does not actually remap the keyboard event into something new. It only adds another event as well.
Is there any way to prevent the original event from going through to the application?
If we take the example above: When I press Left arrow, I want that to be translated to CTRL + PGUP, but I do not want the Left arrow press to go to application as well.
/ermhawi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There _is_ a way to put the keyboard under complete control of Gizmod, but it means that all the other keys will need to be captured and resent through the event bus. You can use the grabExclusiveAccess() function to ensure that only Gizmod receives keyboard events, so in order for the system to see events you're not interested in capturing, you need to manually recreate the event.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am trying to change some of firefox keyboard shoutcuts in the following way:
Right CTRL = CTRL + W (close tab)
Left arrow = CTRL + PGUP (next tab)
Right arrow = CTRL + PGDOWN (prev tab)
I am using gizmod with the following code:
...
if Event.Code == GizmoKey.KEY_RIGHTCTRL:
Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_W, GizmoKey.KEY_LEFTCTRL])
return True
elif Event.Code == GizmoKey.KEY_LEFT:
Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEUP, GizmoKey.KEY_LEFTCTRL])
return True
elif Event.Code == GizmoKey.KEY_RIGHT:
Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_PAGEDOWN, [GizmoKey.KEY_LEFTCTRL])
return True
else:
# unmatched event, keep processing
return False
...
The problem is that when I press the left arrow key it seems to generate two "CTRL + PGUP" which results in two steps in the tab list, not one as I would expect. Same problem for the right arrow.
Am I doing something wrong here?
/ermhawi
Hey Ermhawi,
There are actually 3 possible states for any standard keyboard event, where Event.Value signifies the state:
- Event.Value == 0 means the button has been release
- Event.Value == 1 means the button has been pressed
- Event.Value == 2 means the button has been repeated (pressed and held)
So I think all you should need to do is (where ____ is a tab):
if Event.Value == 0:
____if Event.Code == GizmoKey.KEY_RIGHTCTRL:
________Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_W, GizmoKey.KEY_LEFTCTRL])
________return True
...
Make sense?
Tim.
That solved the problem, thank you very much!
/ermhawi
Excellent, good to hear!
Hi, I have tried to extend this a bit further and I have come to realize that this does not actually remap the keyboard event into something new. It only adds another event as well.
Is there any way to prevent the original event from going through to the application?
If we take the example above: When I press Left arrow, I want that to be translated to CTRL + PGUP, but I do not want the Left arrow press to go to application as well.
/ermhawi
Really? How exactly did you do the remapping?
There _is_ a way to put the keyboard under complete control of Gizmod, but it means that all the other keys will need to be captured and resent through the event bus. You can use the grabExclusiveAccess() function to ensure that only Gizmod receives keyboard events, so in order for the system to see events you're not interested in capturing, you need to manually recreate the event.