Ubuntu – How to make the double quote behave as a dead key except when it is used in combination with itself

keyboard-layout

When I use a keyboard, I expect the following behaviours (and I rely on these behaviours):

  • Press ", release ": Should remember the key as a dead key
  • Press ", release ", press <space>, release <space>: Should print "
  • Press ", release ", press ", release ": Should print ""

I understand that this behaviour is defined by a keyboard layout, so I did some research.

On keyboard layout "English – US with dead keys", I get the top 2 behaviours that I prefer, but the last behaviour is not fulfilled, and I get the weird character ¨ when I try that.

On keyboard layout "English – US with AltGr dead keys", I only get the last behaviour, but the key doesn't behave dead anymore.

How can I modify the keyboard layout to fulfill the 3 behaviours I expect when I use a keyboard?

Best Answer

After trying differend ways for this problem, I eventually found a solution with help in chat for this problem

The root cause of the problem is actually caused by the fact that Linux does not have an dead_apostrophe and a dead_quotedbl by default, so the default "us dead keyboard layout" have either mapped a dead_acute or a non dead key mapped to ".

This meant this problem is not being fixable by making your own custom keyboard layout, as I was suggested in the chat.

After further research and the just is time learning of new keywords to search, I found this solution on Unix & Linux StackExchange, what helped me solve the problem.

I followed the following steps listed in that answer:

  1. sudo apt install uim
  2. echo 'export GTK_IM_MODULE="uim"' >> ~/.profile
  3. echo 'export QT_IM_MODULE="uim"' >> ~/.profile
  4. curl 'https://gist.githubusercontent.com/guiambros/b773ee85746e06454596/raw/0ea6d7f7cf9a6ff38b4cafde24dd43852e46d5e3/.XCompose' > ~/.XCompose
  5. Configure my keyboard layout to "English (US - intl with dead keys)"
  6. Rebooted Ubuntu (according to the comments, logging out and in is enough)

After these steps, I managed to fulfill the following expectations I had about my keyboard:

  • Press ", release ": Should remember the key as a dead key
  • Press ", release ", press <space>, release <space>: Should print "
  • Press ", release ", press ", release ": Should print ""