LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-07-2010, 06:35 AM   #1
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45
Blog Entries: 1

Rep: Reputation: 16
Question Using Keyboard key as Mouse Button (in this order)


Hi,

*The Why:*
The mouse buttons on my machine are frustratingly loud, unreliable and hard to press down. (the touchpad thingy that *moves* the mouse works great though)

*The What*
I would like to map a certain (unused) keyboard key I have, to do the job that the left mouse button does (i.e. the opposite of what tons of mouse-keyboard mapping programs do).

I'm open for suggestions on how to accomplish this, but I would prefer using xmodmap, possibly in conjunction with xdotool. Thus, I need someway to map events as follows: (button1=leftmouse; keycode123=keyboard key alternative)

KeyPress 123 ---> ButtonPress Button 1
Keyrelease 123 ---> ButtonRelease Button 1

Compiz is also a great way to map stuff to xdotool commands, but it doesn't handle separate KeyDown/KeyUp event.

Would really like some suggestions from the community! tnx!
 
Old 05-09-2010, 10:36 AM   #2
sploot
Member
 
Registered: Sep 2009
Location: Phoenix, AZ
Distribution: Gentoo, Debian, Ubuntu
Posts: 121

Rep: Reputation: 27
Have you looked into xmodmap? It allows you to remap keys, I dont know if it will allow you to use your mouse buttons though.
 
Old 05-09-2010, 11:20 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Why not get a new mouse?

Or are you talking about a built-in laptop touchpad?
 
Old 05-09-2010, 12:10 PM   #4
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,781
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Along these same lines, is there a unversal list of scancodes and keycodes and X11 friends (like the ASCII and UNICODE lists) that all vendors are supposed to respect?

What is the best way to get a list of all of these codes that are in current, active use on my computer?

~~~ 0;-Dan
 
Old 05-09-2010, 12:21 PM   #5
sploot
Member
 
Registered: Sep 2009
Location: Phoenix, AZ
Distribution: Gentoo, Debian, Ubuntu
Posts: 121

Rep: Reputation: 27
Quote:
Originally Posted by SaintDanBert View Post
Along these same lines, is there a unversal list of scancodes and keycodes and X11 friends (like the ASCII and UNICODE lists) that all vendors are supposed to respect?

What is the best way to get a list of all of these codes that are in current, active use on my computer?

~~~ 0;-Dan
To find particular keycodes, use
Code:
xev
If you want to know which codes to use for special buttons, look at [code]/usr/share/X11/SKeysymDB[code] To see which codes are currently mapped to what on your machine, look at xmodmap and the keymap you have installed.
 
Old 05-09-2010, 01:10 PM   #6
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by sploot View Post
Have you looked into xmodmap? It allows you to remap keys, I dont know if it will allow you to use your mouse buttons though.
Yup, I use xmodmap for other stuff. Not sure about press/release events though.

I found this cool daemon:
actkbd

It might just be the solution. I'll post back if I accomplish anything with this.
 
Old 05-09-2010, 01:12 PM   #7
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by MTK358 View Post
Why not get a new mouse?

Or are you talking about a built-in laptop touchpad?
Yes, I'm talking about the touchpad buttons. Forgot to mention that.
 
Old 05-09-2010, 05:09 PM   #8
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Yes, actkbd solved it for me.
A how-to that may help:

1) Disable (as far as X is concerned) key 123 with xmodmap

Code:
xmodmap -e 123 ""
#(rough description)

This is probably not necessary if you figure out how to "grab" the event with actkbd. I did not. If the key is mapped to any symbol by X (in my case the 'section' symbol, what on earth?!) and it is not grabbed, then it will still produce that symbol as well as the mouse event. This is not desireable.

2) Map 123 keypress/keyrelease to xdotool mousedown/mouseup

Code:
#File /etc/actkbd.conf

<keycode ("123")> :key : :xdotool mousedown 1
<keycode ("123")> :rel : :xdotool mouseup 1
# NOTE!! <keycode ("123")> is not the keycode reported by xev. You may find the code to use with actkbd by running
# sudo actkbd -s
# and press the physical key on you keyboard.

#NOTE!! LOL
#Also I found that the daemon stole my keyboard interface sometimes, making it impossible to communicate with the #machine, including killing the daemon. It helped a lot to run a watchdog script to 'killall actkbd' after a 20 second #timeout, until everyting is set up ok. But those who know how to use this daemon correctly probably don't need to bother with this

3) Start actkbd daemon

Code:
sudo actkbd -D
Key 123 now behaves exactly as left mouse button (although a lot more accessible, quiet and easy to press!)
Success!

EDIT: This is a very ugly how-to. If I can help with anything, please let me know.

Last edited by kopatops; 05-09-2010 at 05:46 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind Mouse Button Combination to Keyboard Key Combination? neoAKiRAz Linux - Desktop 0 05-04-2007 12:49 PM
Bind key to 3rd mouse button moo-cow Linux - Software 0 02-23-2007 06:40 PM
howto map mouse button to keyboard key lopette Linux - Software 2 09-16-2004 03:18 PM
Map Mouse Button to Key Parksy Linux - Hardware 0 01-07-2004 08:00 PM
Map Windows key to middle mouse button? elconde Linux - Hardware 1 12-28-2002 01:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration