# F10 function key in rxvt-unicode and st



## Sevendogsbsd (Nov 13, 2018)

I have an odd issue with 2 different terminal emulators: x11/rxvt-unicode and x11/sterm. Neither terminal responds to the "F10" key, when using sysutils/htop or misc/mc. This key is used to exit both applications. The F1-F9 keys work  fine.

I have looked at the code for x11/st and it is using (of course) the appropriate keycodes for F10. x11/xterm and x11/uxterm work fine.

Is the F10 key special for some reason? I am using FreeBSD 11.2 P4 Release.

Thanks in advance!


----------



## aragats (Nov 13, 2018)

Sorry, what is *x11/st*? I don't see that port...
Here F10 works fine in misc/mc running in x11/rxvt-unicode.
What's your DE/WM?


----------



## Sevendogsbsd (Nov 13, 2018)

st is "sterm" - from suckless.org. It's in ports, sorry, fixed my OP - running x11-wm/dwm currently. Interesting, wonder if it's my keyboard, but x11/xterm works fine...keyboard is new too.


----------



## aragats (Nov 13, 2018)

x11/sterm outputs *~* (tilde) when I press F5, F6, F7, F8, F10, F11, F12.
Definitely something is wrong with it.
By the way, I use dwm too, but not from ports.


----------



## Sevendogsbsd (Nov 13, 2018)

Interesting - here is the line of code that corresponds to the F10 key:

```
{ XK_F10,           XK_NO_MOD,      "\033[21~",      0,    0},
```

Sure looks like a tilde to me...according to this site (Keycodes), the keycode for F10 should be "^[[21~". Not sure how that translates...


----------



## yuripv (Nov 13, 2018)

To see what code F10 produces, simply run `cat` in the terminal and press it.


----------



## aragats (Nov 13, 2018)

That's correct, "\033" is an easier way to write the same. I tried replacing it with the actual symbol by using Ctrl-V F10, but nothing changed after recompilation.
There is something else...


----------



## Sevendogsbsd (Nov 13, 2018)

OK, more research is needed...my favorite is x11/rxvt-unicode, I was just playing with x11/sterm - I'll give x11/rxvt-unicode a test after work and see what the F10 produces in the terminal.


----------



## aragats (Nov 13, 2018)

The problem has to be somewhere here, look in x.c:
	
	



```
1647 char*
1648 kmap(KeySym k, uint state)
1649 {   
1650     Key *kp;
1651     int i;
1652     
1653     /* Check for mapped keys out of X11 function keys. */
1654     for (i = 0; i < LEN(mappedkeys); i++) {
1655         if (mappedkeys[i] == k)
1656             break;
1657     }
1658     if (i == LEN(mappedkeys)) {
1659         if ((k & 0xFFFF) < 0xFD00)
1660             return NULL;
1661     }
1662     
1663     for (kp = key; kp < key + LEN(key); kp++) {
1664         if (kp->k != k)
1665             continue;
1666         
1667         if (!match(kp->mask, state))
1668             continue;
1669         
1670         if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
1671             continue;
1672         if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2)
1673             continue;
1674         
1675         if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
1676             continue;
1677         
1678         return kp->s;
1679     }
1680     
1681     return NULL;
1682 }
```


----------



## chrbr (Nov 13, 2018)

Dear Sevendogsbsd,
here F10 works for me with .xinitrc

```
LANG=de_DE.UTF-8
export LANG
setxkbmap -layout de
xkbset m
xkbset exp '='m
xmodmap -e "keycode 117=Pointer_Button1"
xmodmap -e "keycode 115=Pointer_Button2"
xmodmap -e "keycode  90=Alt_L"
xmodmap -e "keycode  91=Left"
exec /usr/home/chris/scripts/dwm_status.sh &
xhost + inet:10.0.0.3
exec /usr/local/bin/dwm
```
and /usr/ports/x11/sterm/files/patch-config.def.h

```
--- config.def.h.orig   2018-03-20 20:29:59 UTC
+++ config.def.h
@@ -5,7 +5,7 @@
  *
  * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
  */
-static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
+static char *font = "Liberation Mono:pixelsize=13:antialias=true:autohint=true";
static int borderpx = 2;

/*
@@ -63,7 +63,7 @@ static unsigned int cursorthickness = 2;
static int bellvolume = 0;

/* default TERM value */
-char *termname = "st-256color";
+char *termname = "xterm";

/*
  * spaces per tab
@@ -116,10 +116,10 @@ static const char *colorname[] = {
  * Default colors (colorname index)
  * foreground, background, cursor, reverse cursor
  */
-unsigned int defaultfg = 7;
-unsigned int defaultbg = 0;
-static unsigned int defaultcs = 256;
-static unsigned int defaultrcs = 257;
+unsigned int defaultfg = 0;
+unsigned int defaultbg = 7;
+static unsigned int defaultcs = 9;
+static unsigned int defaultrcs = 1;

/*
  * Default shape of cursor
```
May be it is the faking of xterm, may be it is the keyboard setting in .xinitc which makes it work.

I guess you will succeed since you gave me the pointer to x11-wm/dwm and x11/sterm.


----------



## Sevendogsbsd (Nov 13, 2018)

Interesting - maybe the faking of xterm - xterm works. Aragats found something in some C code in a post above - I am not a C programmer so am not able to tell what is causing the problem by that example.


----------



## Sevendogsbsd (Nov 13, 2018)

I built x11/rxvt-unicode in ports and am using that with my customized x11-wm/dwm and the F10 key works fine in x11-misc/mc. The F10 key still doesn't work in sysutils/htop but the "q" works to quit the app gracefully so I am good with that.

Problem solved, sort of...I was really just monkeying around with x11/sterm because I like the fact I can customize it, so I may play around some more. Will leave the thread open if any enterprising C coders can figure out what might be wrong with x11/sterm, or I can ping the dev to see if he/she knows what the issue might be.


----------

