Converting Keyboard Codes (Solved)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

Converting Keyboard Codes (Solved)

#1 Post by RSH »

Hi.

I have a small Script, that is echoing a code, when I'm pressing a key. It uses the following function:

Code: Select all

KEYBOARD="/dev/input/event0"
checkkey() {
	dd if="$KEYBOARD" bs=16 count=1 2>/dev/null | hexdump | cut -f8 -d ' ' | head -1
}
To call it I do use:

Code: Select all

KEY=$(checkkey)
And it returns the keyboard code.

E.g. for Back-Space: 000e

In another Script I have keyboard code definitions like: 0xff0d (which is Enter or Return). In my mentioned script this returns as: 001c


When I'm just entering 000e I don't get the function working by Back-Space key.

So how can I convert this 001c (for Return/Enter) code to get this form of keyboard code, 0xff0d for the use in a gtkdialog script (GUI)?

Is there a function to do such, or some sort of translation-table anywhere?

Do I have to change anything in the above function, checkkey?

Thanks,

RSH
Last edited by RSH on Sat 23 Aug 2014, 22:24, edited 1 time in total.
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

I have no idea, but the discussion in this thread might give you some ideas.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#3 Post by RSH »

Ok.

Found it and solved.

Running xev will return the code needed. have used this much earlier, but could not remember xev using.

Thanks to Puppus Dogfellow (PM), so: solved.

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#4 Post by Flash »

Use of xev was described in this post near the end of the thread I mentioned. :)

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#5 Post by amigo »

You could also have hexdump show the octal value -or use a similar tool to do so.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#6 Post by RSH »

Flash wrote:Use of xev was described in this post near the end of the thread I mentioned. :)
Yes, thanks for the links.

As I saw your first post and clicked the link, I just remembered where I got the script from. So I just decided to sent a PM to Puppus Dogfellow instead of reading 3 pages of the thread - which was much faster.
amigo wrote:You could also have hexdump show the octal value -or use a similar tool to do so.
I have tried to use option -b (for octal) but this returns a different code each time I pressed back-space key. Option -o returns always an empty string like most of the other options does.

However, xev does the job quite well.

Thanks,

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#7 Post by amigo »

your hexdump is probably busybox.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#8 Post by RSH »

amigo wrote:your hexdump is probably busybox.
Yes!
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

Post Reply