Newbie: Is capturing and changing keyboard input possible?

1,045 views
Skip to first unread message

arry

unread,
Jan 27, 2010, 5:22:41 PM1/27/10
to Chromium-extensions
I haven't actually started developing an extension yet: I'm in the
stage where I'm trying to decide if I should bother trying to make
one. I have something very specific in mind: I want to be able to make
an extension so that the keyboard format in Chrome is essentially
Dvorak, Colemak, or another alternate keyboard format. This means I
need to have it capture all user keyboard input, change it from Qwerty
to whatever, and resend it to whatever page is open.

I've read the API documentation, but I can't find any way to do this.
Do you know if this currently feasible with Chrome's API? Thanks in
advance for your answers!

Ronald Schouten

unread,
Jan 27, 2010, 8:23:34 PM1/27/10
to arry, Chromium-extensions
That's a good question. The content script that you would write and inject into every web page would not have access to the host page's JavaScript. All that is shared is the DOM. I'm not sure where events fit into this. I guess the questions is weather or not a content script can intercept an event and alter it before the host script makes use of it.


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.




--
Ronald Schouten - Web Developer / JavaScript Ninja

Like Google Chrome and Gmail? Try my Gmail Notes extension.
https://chrome.google.com/extensions/detail/hiheeapdnogdfdcbpjpibpllaifndgke

Brian Kennish

unread,
Jan 27, 2010, 9:16:29 PM1/27/10
to arry, Chromium-extensions
On Wed, Jan 27, 2010 at 2:22 PM, arry <rbys...@gmail.com> wrote:
> I've read the API documentation, but I can't find any way to do this.

The capturing part is easy -- see
http://groups.google.com/group/chromium-extensions/browse_thread/thread/479b6e0a43c45b60
for some code to get you started. The changing part will probably be
hard. IE makes the "keyCode" property writeable, which would be a
straightforward way to universally transform keyboard input, but I
don't think other browsers do.

Dhruva Sagar

unread,
Jan 27, 2010, 11:31:18 PM1/27/10
to Brian Kennish, arry, Chromium-extensions
Hi,

Have a look at my simple extension called Ninjawords Lookup https://chrome.google.com/extensions/detail/jgffckppegfbkkajkliaailkldochkia
I am doing exactly what you desire to you. Hope it helps.

Thanks & Regards,
Dhruva Sagar.




Brian Kennish

unread,
Jan 28, 2010, 11:57:44 AM1/28/10
to Dhruva Sagar, arry, Chromium-extensions
On Wed, Jan 27, 2010 at 8:31 PM, Dhruva Sagar <dhruva...@gmail.com> wrote:
> Have a look at my simple extension called ...

> I am doing exactly what you desire to you.

Where in your extension code are you transforming keyboard input
(e.g., the user types "a", you output "z")?

arry

unread,
Jan 28, 2010, 1:28:58 PM1/28/10
to Chromium-extensions
Looking at shortcut.js and keycode.js, it seems that he's had to jump
through quite a few hoops to be able to intercept browser key events
for even a simple shortcut keycode, Control+Alt-Shift-N; maybe the
same sort of code will enable me to intercept key events without
modifier keys too. I'll take a closer look at it.

If anyone else has any other information, particularly on things
unique to Chrome, please let me know too.

On Jan 28, 9:57 am, Brian Kennish <bkenn...@chromium.org> wrote:

Bill.Keller

unread,
Jan 31, 2010, 6:32:03 AM1/31/10
to Chromium-extensions
I'm interested to know what Chrome developers would suggest doing when
it comes to creating keyboard shortcuts in our extensions. There seems
to be no guidelines yet in the extension documentation.

Should we even be overwriting Chrome's default keyboard shortcuts, to
begin with?
If so, what's the best way to do it?

Should we be creating a shortcut set that would never interfere with
Chrome's defaults?

I've been able to get a keyboard shortcut working (http://
code.google.com/p/delicious-chrome-extension/source/browse/trunk/
addDelicious.js)
and it's in use on the following extension:
https://chrome.google.com/extensions/detail/gclkcflnjahgejhappicbhcpllkpakej

But I've been struggling with what keyboard shortcut to use. In some
cases the shortcut provided overwrites Chrome's default (Alt+D), in
other cases it does not (Ctrl+D).

On Jan 28, 1:28 pm, arry <rbysam...@gmail.com> wrote:
> Looking atshortcut.js and keycode.js, it seems that he's had to jump


> through quite a few hoops to be able to intercept browser key events

> for even a simpleshortcutkeycode, Control+Alt-Shift-N; maybe the

Naruki

unread,
Jan 31, 2010, 8:58:37 PM1/31/10
to Chromium-extensions
I would suggest pick something that makes the most sense and if it
conflicts with something, pick something least likely to matter.

Then make it user-configurable.


On Jan 31, 8:32 pm, "Bill.Keller" <sweater...@gmail.com> wrote:
> I'm interested to know what Chrome developers would suggest doing when
> it comes to creating keyboard shortcuts in our extensions. There seems
> to be no guidelines yet in the extension documentation.
>
> Should we even be overwriting Chrome's default keyboard shortcuts, to
> begin with?
> If so, what's the best way to do it?
>
> Should we be creating a shortcut set that would never interfere with
> Chrome's defaults?
>
> I've been able to get a keyboard shortcut working (http://
> code.google.com/p/delicious-chrome-extension/source/browse/trunk/
> addDelicious.js)

> and it's in use on the following extension:https://chrome.google.com/extensions/detail/gclkcflnjahgejhappicbhcpl...

Reply all
Reply to author
Forward
0 new messages