2

I've got ubuntu running on chromebook using crouton.

How do I map the search key to the ctrl action.

Similar to this, swapping the caps lock key and the ctrl key.

/usr/bin/setxkbmap -option "ctrl:swapcaps"

Update

I've still had no luck :-(, I've swapping the like this, in a ~/.Xmodmap file:

clear control
clear mod4

keycode 105 =
keycode 206 =

keycode 37 = Control_L NoSymbol Control_L
keycode 134 = Control_R NoSymbol Control_R
keycode 133 = Super_L NoSymbol Super_L

add control = Control_L
add control = Control_R
add mod4 = Super_L

But still no luck, any help suggestion would be much appretaited.

Martinffx
  • 171

4 Answers4

3

I have Acer C720 Chromebook, here is what I did to map search key to control

You can use xev to check the keycode for your search key, and which key it is mapped to. For my chromebook, search key is mapped to Super_L by default.

First, create file .Xmodmap at your $HOME directory with content below

clear control
clear mod4
keycode 133 = Super_L
add control  = Control_L Control_R Super_L
add mod4 = Super_L Super_R

Next, need to make sure xmodmap load ~/.Xmodmap file when you start you linux using sudo startxfce4 in chromebook terminal. Create file ~/.xinitrc with content below

if [ -s ~/.Xmodmap ]; then
    xmodmap ~/.Xmodmap
fi

Last step is to logout your xfce environment and restart it from chromebook terminal.

For reference, you can look at Section Special keys/signals from Here And another reference from crouton: Here

none
  • 3
yongzhy
  • 131
  • 3
1

I was having the same problem you were.

this site shows how to find out the key being pressed.

showkey --keycodes

then by pressing the search key I got 125 (I was on HP 14" chromebook, so it could be different, but I'm thinking it should be the same)

Now use keycode 125 to map to control
Create a new file with the following lines:

keymaps 0-127
keycode 125 = Control

File = /usr/share/keymaps/Caps2Ctrl.map (I created the keymaps directory and created a new file)

Now

sudo loadkeys /usr/share/keymaps/Caps2Ctrl.map

and its done!
This method was from the emacs wiki

1

The following shell script works to make the Search key another Control key on a Samsung Chromebook when swapping the Search key and the Control key is activated under ChromeOS. In addition, on the system where this worked, the "keyboard" target of crouton was not loaded. (And, yongzhy's solution above doesn't work --- the Search key still expresses "mod4" in addition to "control", and ".xinitrc" doesn't seem to be executed.)

#! /bin/bash -f
xmodmap -e 'remove mod4 = Super_L'
xmodmap -e 'remove control = Control_L'
xmodmap -e 'keycode 133 = Control_L'
xmodmap -e 'add control = Control_L'
xmodmap -e 'keycode 134 = Control_L'
xmodmap -e 'remove mod4 = Control_L'
xmodmap -e 'keycode 207 = Control_L'
xmodmap -e 'remove mod4 = Control_L'

Note that running "xmodmap" once on a file containing all of these commands did not work, for some reason. (Something which might point to a race condition between some ChromeOS keyboard driver weirdness and "xmodmap", which might mean that other systems might need "sleep" commands inserted in this script in auspicious places.)

In addition, if you are running Xfce as your desktop, and want to add this to the automatically started programs in the session settings, you should add a "sleep X" to the start of the file, where X = 3 worked for me, but I assume it could vary depending on the speed of your system and what other processes are run by Xfce at startup.

Based on my experience, if this doesn't work, I suggest trying the following pseudo-code:

<Do what you would ordinarily do to switch the keys>
while "xmodmap -pm" shows that "mod4" includes keys:
    for key in <keys assigned to mod4>:
        xmodmap -e 'keycode <keycode(key)> = Control_L'
        xmodmap -e 'remove mod4 = Control_L'

(This obviously won't work if you want to have some key expressing "mod4".)

0

On my Pixel the search key is defaulted to the Super key. I have not tested this but I assume something like

/usr/bin/setxkbmap -option "super:ctrl"
Trevor
  • 1
  • This will not work because super:... is not an option for setxkbmap (all options can be found in /usr/share/X11/xkb/rules/base.lst) – Gerhard Burger Jan 24 '14 at 07:11
  • /usr/bin/setxkbmap -option "ctrl:swap_lwin_lctl" works for my chromebook pixel. – Lyle Apr 14 '20 at 22:32