Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old July 28th, 2011, 02:04 AM   #1 (permalink)
Junior Member
 
Join Date: Jul 2011
Posts: 27
 
Device(s): Generic noname android 2.2 tablet
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tannim Send a message via Yahoo to tannim
Default Possible to Intercept keyboard key presses?

I had an idea for an application, but I don't know if it's possible or not.

Can a program sit in the background and intercept keypresses, convert the keypresses from one letter to another, and send it to whatever program you are working in as though the new letter is what you typed?

As qwerty is the only layout choice for hardware keyboards and I don't have root on my tablet, I want to use this as a work around.

If I were to press "s" on my hardware usb keyboard. The program would intercept the "s" before it got to whatever textbox and convert it into the dvorak key equivalent of "o". That o would then be passed to the program as a normal keypress.

if I were to press asdfg on the qwerty aoeui would be sent instead.

Is this possible to do? I thought it best to ask before I waste hours trying to learn how to write the program.

List of changes I would make in a pseudocode case statement format.
Select Case Key
#Comment - Number Row Key changes
- = change to [
= = change to ]
#Comment - Top Row Key changes
q = change to '
w = change to ,
e = change to .
r = change to p
t = change to y
y = change to f
u = change to g
i = change to c
o = change to r
p = change to l
[ = change to /
] = change to =
#Comment - Middle Row Key changes
#Comment - A = A Same in Dvorak as Qwerty Handled by the Else
s = change to o
d = change to e
f = change to u
g = change to i
h = change to d
j = change to h
k = change to t
l = change to n
; = change to s
' = change to -
#Comment - Bottom Row Key changes
z = change to ;
x = change to q
c = change to j
v = change to k
b = change to x
n = change to b
#Comment - M = M Same in Dvorak as Qwerty Handled by the Else
, = change to w
. = change to v
/ = change to z
else
#Comment - For keys that are the same in Dvorak as in Qwerty
pressed key = pressed key
end case

tannim is offline  
Last edited by tannim; July 28th, 2011 at 03:18 AM. Reason: added a bit
Reply With Quote
Sponsors
Old July 28th, 2011, 09:23 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

You can program full keyboard replacements and should in theory be able to handle hardware keyboards with that same replacement.

However you can't "sit in the background" and intercept. The user would be fully aware and have to go through the process of choosing your keyboard.

This might help:
InputMethodManager | Android Developers

Creating an Input Method | Android Developers

Quote:
Intercepting hard key events

Even though the input method window doesn't have explicit focus, it receives hard key events first and can choose to consume them or forward them along to the application. For instance, you may want to consume the directional keys to navigate within your UI for candidate selection during composition. Or you may want to trap the back key to dismiss any popups originating from the input method window. To intercept hard keys, override InputMethodService.onKeyDown() and InputMethodService.onKeyUp(). Remember to call super.onKey* if you don't want to consume a certain key yourself.
alostpacket is offline  
Reply With Quote
Old December 13th, 2011, 08:44 PM   #3 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 20
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tannim, Have you got your project done? Thanks!
isup is offline  
Reply With Quote
Reply

Bookmarks

Tags
dvorak, keyboard


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:43 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo