Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Right-Click with a Macbook

  1. #1
    Join Date
    Sep 2008
    Beans
    8

    Right-Click with a Macbook

    I'm having an issue with Ubuntu. I cannot double-click, as ctrl+click is not working properly. I cannot figure out how to set the keyboard to the correct settings, can anyone give me a step-by-step guide?

  2. #2
    Join Date
    May 2007
    Location
    Warwickshire, UK
    Beans
    336

    Re: Right-Click with a Macbook

    -[Discipline] - Macbook Pro 5,3 - Intel Core2Duo 2.66Ghz, 4Gb RAM, Nvidia 9400M + 9600GT, 320Gb HDD, Mac OSX 10.7.1 Lion
    -Windows free since May 2007.

  3. #3
    Join Date
    Oct 2005
    Beans
    720

    Re: Right-Click with an Apple keyboard

    Right- and middle mouse-clicks can be simulated on Apple keyboards and touchpads with various combinations of keys and taps. This can present a problem in some drawing applications (like XFig) where you would need an extra hand to terminate a line... What's needed here is a set of single-key right- and middle mouse-click emulations. These might also come in handy in other situations, as they free up a hand (useful when holding a coffee mug) and prevent accidental clicks when merely doing a two-finger scroll on a touchpad.

    It is a simple matter to assign right- and middle mouse-clicks to a some little-used keys, like the right-Alt and right-Command keys on any recent Apple keyboard. It doesn't matter much which keyboard you have specified in your Ubuntu setup, I usually pick the PC104 spec for my Apple Aluminum wireless US keyboard. Now, this is what you should do:

    1. Install the "xev" package (if it isn't already installed), then in a terminal give the "xev" command. A little window opens with a small square: put the cursor in that square. Then hit the right-Alt and right-Command keys and watch the output for the keycodes, probably 108 and 134, and write them down. Keycodes do change from time-to-time, though, so check them yourself. Then close the little window by clicking on the X; this terminates xev.

    2. Make a little script, like /usr/local/bin/keyboard (you need root privileges for that),
    Code:
    #!/bin/sh
    xmodmap -e "keycode 108 = Pointer_Button3"
    xmodmap -e "keycode 134 = Pointer_Button2"
    xkbset m
    where you should substitute the keycodes on your keyboard if different from mine. Make this script executable with the command
    Code:
    sudo chmod a+x /usr/local/bin/keyboard
    3. Make sure that the "xkbset" package is installed, then find where your keyboard settings can be modified and enable control of the mouse with the keyboard, so that the "xkbset m" command in the script will work.

    4. Finally, as user give the command "keyboard", and now those two keys should work as right- and middle mouse-clicks. If this works, then add the command "/usr/local/bin/keyboard" to the startup applications.

    N.B. I'm a little vague on where these system settings for keyboard and startup programs are located. That's intentional, as their location has changed several times over the past years. You should look for System settings, or some such...

    NN.BB. Usually I add a few more key assignments to the above script, like putting the §/± and `/~ key assignments right
    Code:
    xmodmap -e "keycode 94 = section plusminus"
    xmodmap -e "keycode 49 = grave asciitilde"
    Check these keycodes with xev as above.

    These key-assignments don't interfere with the system settings for the keyboard layout. For example, you can still in the layout specify the left-Alt key as the Compose key (for making accented letters on a US-keyboard); and the left-Command key (usually called left-Windows key...) as Third-level chooser to produce a EuroSign.

    Have fun with your new key assignments!
    Last edited by hajk; February 12th, 2012 at 09:15 PM. Reason: To make it an ever more perfect post...

  4. #4
    Join Date
    Aug 2005
    Location
    Huntsville, AL, USA
    Beans
    7,526
    Distro
    Ubuntu

    Re: Right-Click with a Macbook

    good post hajk, I think I will post this one in the FAQ.

  5. #5
    Join Date
    Oct 2005
    Beans
    720

    Re: Right-Click with a Macbook

    Glad to be of help.

    BTW, the reason I prefer using keys for clicking instead of tapping the touchpad with one or more fingers is a very practical one: just trying to move the cursor (with one finger) or doing a two-finger scroll was forever giving me mouse clicks instead (and driving me mad in the process). I guess I'm heavy-handed when I get absorbed in work... The only touchpad nicety that I allow myself is one-finger vertical scrolling along the right edge of the touchpad.

  6. #6
    Join Date
    Aug 2008
    Location
    Switzerland
    Beans
    19
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Right-Click with a Macbook

    Thanks hajk for this helpful post
    I tried it on Ubuntu 8.10, Macbook Pro Core2Duo with the your script for the right mouse click and it works. Except of one "not found" message I receive starting the script "keyboard" manually:

    ~$ keyboard
    /usr/local/bin/keyboard: 3: xkbset: not found
    Although it does work soemthing seems to be not working as supposed?
    Perhaps you might have a look at it?
    Best regards,
    tp42

  7. #7
    Join Date
    Oct 2005
    Beans
    720

    Re: Right-Click with a Macbook

    You need the "xkbset" package installed for that. This is (was) mentioned in item 3 a bit as an afterthought, I've now given this requirement a bit more prominence. Thanks for the feedback.

  8. #8
    Join Date
    Aug 2007
    Location
    Kardjali, Bulgaria
    Beans
    31
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: Right-Click with a Macbook

    I mapped my right Apple key for right clicking by running the command

    xmodmap -e "keycode 134 = Pointer_Button3" & xkbset m

    works for me.

    However, adding this command to System->Preferences->Startup Applications produces no effect. Is something overwriting the effect of this command at log on, or am I doing something wrong?

  9. #9
    Join Date
    Oct 2005
    Beans
    720

    Re: Right-Click with a Macbook

    The & is a separator for two commands, while you can only give a single command in Startup Programs. So, gather those two commands in a script, make it executable, then call that script in Startup Programs.

  10. #10
    Join Date
    Apr 2007
    Location
    Arkansas, USA
    Beans
    334

    Lightbulb Re: Right-Click with a Macbook

    Personally, I'm still a fan of using the mac-style CONTROL + Click to get a right-click. If that is what you would like to do, then here is how to go about it:

    Hit ALT-F2 and give this command:
    Code:
    gksudo gedit /etc/default/mouseemu
    It'll prompt you for a password.

    Now just set it up like this:

    Code:
    #MID_CLICK="-middle 0 68"         # F10 with no modifier
    MID_CLICK="-middle 125 272"      # Left Apple Key (LEFTMETA) + click
    #RIGHT_CLICK="-right 0 87"        # F11 with no modifier
    RIGHT_CLICK="-right 29 272"      # Left Ctrl + click
    #SCROLL="-scroll 56"              # Alt key
    #TYPING_BLOCK="-typing-block 300" # block mouse for 300ms after a keypress
    And once you save, log out, and log back in, control-click will handle your right-click issues.
    ---------------------------------------------------
    Linux: Because my business ISN'T "Everybody's Business"

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •