# Need help on setting keymap



## one_eye_pirate (Sep 7, 2019)

Hi,

I'm a FreeBSD newbie and I've just installed FreeBSD 12.0 in virtualbox.

As root and using the command "kbdmap", I have tested my keymap both with:
- Portuguese: "pt.kbd"
and
- Portuguese (accent keys): "pt.acc.kbd"

However, my problem is that none of this two keymaps work for me.
They work for almost all keys, but some are incorrect.

As an example, the "ç" key does nothing when I press it.
And the "«" key writes "=".

I think my keyboard model is "pc 105 pt", because in linux the command "cat /etc/default/keyboard" gives me this output:
XKBMODEL="pc105"
XKBLAYOUT="pt"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"

I have read the FreeBSD Manual that explains Localization, and I created and added this to "~/login.conf", but it didn't work:

```
me:\
    :charset=ISO-8859-1:\
    :lang=pt_PT.ISO8859-1:
```

What I would like to achieve is this:
- keep my system language in US English
- use the portuguese keyboard mentioned above, but with all keys working correctly

Can somebody help me on solving this?


----------



## Terpentijn (Sep 8, 2019)

Try this:
`cd /usr/local/etc/X11/xorg.conf.d/`

Create a file 00-keyboard.conf with your favorite editor


```
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbModel" "pc105"
        Option "XkbVariant" "intl"
EndSection
```
With this file in place, all accented letters should work. I use an us layout keyboard. You might have to change it, if you use some kind of Portuguese keyboard.


----------



## Minbari (Sep 8, 2019)

See: HowTo: have/display multiple keyboard layouts on Unix-like


----------



## T-Daemon (Sep 8, 2019)

one_eye_pirate said:


> As an example, the "ç" key does nothing when I press it.


Works for me with pt.kbd and pt.acc.kbd (in the virtual console, with UTF-8 set).


one_eye_pirate said:


> What I would like to achieve is this:
> - keep my system language in US English


In this case don't set any portuguese localization, rather edit /etc/login.conf and set charset and lang to UTF-8:
         :

```
....
         :ignoretime@:\
       *  :charset=UTF-8:\*
         *:lang=en_US.UTF-8:\*
         :umask=022:
```
[EDIT] Run afterwards 
`cap_mkdb /etc/login.conf`



one_eye_pirate said:


> - use the portuguese keyboard mentioned above, but with all keys working correctly


It isn't clear if you meant keyboard support in virtual console as well or only in xorg. In case you want support in virtual console too report back.

For xorg, in case configuring the xorg file doesn't work, I couldn't make it work, maybe overlooked something, executing `setxkbmap pt` will give a fully supported portuguese keyboard. Set the command in e.g. .xinitrc.


----------



## Terpentijn (Sep 8, 2019)

T-Daemon said:


> Works for me with pt.kbd and pt.acc.kbd (in the virtual console, with UTF-8 set).
> 
> In this case don't set any portuguese localization, rather edit /etc/login.conf and set charset and lang to UTF-8:
> :
> ...


Hijacking this thread because you mentioned it also works in a vt. I use us.acc.kbd and UTF-8 settings but I have no idea how to get accented letters in the vt. Xorg works flawless. I guess I have to use some kind of dead key but I don’t know which one.


----------



## T-Daemon (Sep 8, 2019)

Terpentijn said:


> I have no idea how to get accented letters in the vt.


There is a pdf (direct download) document explaining how the accent characters are typed  (I'm sure there are many online information on the topic, I picked the first result in a web search) only you need to press also *AltChar* (*AltGr*). E.g. for *Ã* press *AltChar*+*Shift*+*~* then *Shift*+*A*.


----------



## one_eye_pirate (Sep 9, 2019)

I'm going to try the above solutions.

I'm on console, I don't have a desktop environment yet.

And I wasn't using UTF8, but ISO8859-1. 
However, I prefer UTF8 and I will try that.

Thank you all for your help.


----------



## T-Daemon (Sep 9, 2019)

You won't get a fully supported  portuguese keyboard  on the console without modifying the keymap file.

Follow these steps:

Have a hexadecimal UTF-8 encoding table at hand e.g. here.

You are running FreeBSD 12, I asume you haven't changed the vt(4) provided virtual consoles to syscons(4) provided.

`cd /usr/share/vt/keymaps`
(for syscons: `cd /usr/share/syscons/keymaps`)
`cp pt.acc.kbd pt.acc2.kbd`
`vi pt.acc2.kbd`

Replace scancode 013, base colon, from `'='` to `0xab` for*《 *( which you can find in the UTF-8 hexadecimal table in the link above). For *》*  change to `0xbb` in the shift colon. In alt, alt shift set `nop`.

The file edited is write protected, but write can be forced on in vi(1) with: `esc` `:w!` . If you are using another editor chmod(1) the file to write before editing, and after editing to read only back.

For the missing *£, §* signs when pressing *AltGr*+*3* and +*4* take *@* as example and set the hexadecimal numbers accordingly.

I couldn't figure out the little underscore *a* and *o* key, right of the *ç* key.

Execute `kbdmap`, choose pt.acc2, test it. To make it permanent, set `keymap="pt.acc2"` in /etc/rc.conf.

For reference: kbdmap(5)


----------



## T-Daemon (Sep 9, 2019)

T-Daemon said:


> I couldn't figure out the little underscore *a* and *o* key, right of the *ç* key.


I was looking in the hexadecimal UTF-8 table for underscor *a* and *o*, but it's just little *a* and *o*.

Replace in /usr/share/vt/keymaps/pt.acc2.kbd, scancode line 040, base colon, `nop` with `0xba`, in shift colon `0xaa`.

Typing the key will get underscore *a* and *o*.

Now we got a fully supported portuguese keyboard.


----------



## one_eye_pirate (Sep 9, 2019)

Thank you, T-Daemon. I will try it.


----------

