Can I use Escape key in mobile touchscreen keyboard?

I was using “Escape” key as a deadkey for Windows (physical keyboard layout).

I want to use “Escape” as deadkey in mobile (touchscreen keyboard layout). But when I compile, it gives error. Is is that there is no support for Escape key in mobile touchscreen keyboard layout? Or, am I missing something?

Can anyone help me?

The default mobile touchscreen layout does not include an “Escape” key. If you strongly want one, you’ll need to modify the OSK layout to include “Escape” somewhere. That said, keep in mind that touch layouts give you additional ways to produce keys, some of which may be more intuitive to prospective keyboard users.

Many times, when a keyboard’s “hardware” layout is reliant on deadkeys, its touch layout can instead provide longpress subkeys that directly output the desired text. The default keyboard for our mobile Keyman apps (SIL EuroLatin) does this and is a good example. Where two hardware keystrokes are required (a normal key + a dead key) for the hardware layout, its touch layout usually provides longpress subkeys under the “normal” key to produce the same result.

It’s usually best to avoid deadkey use in touch layouts, though I don’t think we’ll stop you outright if you’re very sure you’d prefer deadkey use over other approaches like longpress subkeys.

To add to what @joshua_horton wrote, if you add an Escape key to the layout, you should use the key identifier T_ESC, not K_ESC, because the Escape key is a reserved key. You’d need to tweak rules to handle both T_ESC and K_ESC in your code, e.g.

store(esc) [T_ESC] [K_ESC]

... + any(esc) > ...

But I would encourage you to think about more visual ways of selecting keys, such as longpress, as @joshua_horton wrote.

I tried, it works for physical keyboard. But it gives compilation error when touchscreen keyboard layout is included.

The idea is that when after a, e, i, o and u, if I press Escape (deadkey) followed by RALT K_NP8, the letters should move up as diacritical element. Similarly, with , and -, it should move down with RALT K_NP2; and with /, it should move to the center with RALT K_NP5.

For this, I used the following for Layout (Code):-

store(&NAME) 'useless'
store(&TARGETS) 'windows mobile'
store(&VISUALKEYBOARD) 'useless.kvks'
store(&LAYOUTFILE) 'useless.keyman-touch-layout'
store(esc) [T_ESC] [K_ESC]
store (no_key) 'aeiou' c no= North ==> Move up
store (no_item) U+0363 U+0364 U+0365 U+0366 U+0367
store (so_key) ",`-" c so= South ==> Move down
store (so_item) U+0339 U+0316 U+0331
store (ce_key) "/" c ce= Center ==> Move to center
store (ce_item) U+0338
begin Unicode > use(main)
group(main) using keys
+ any(esc) > dk(dead1)
any(no_key) dk(dead1) + [RALT K_NP8] > index(no_item,1)
any(so_key) dk(dead1) + [RALT K_NP2] > index(so_item,1)
any(ce_key) dk(dead1) + [RALT K_NP5] > index(ce_item,1)

I used the following for Touch Layout (Code):-

{
  "phone": {
    "font": "Tahoma",
    "layer": [
      {
        "id": "default",
        "row": [
          {
            "id": 1,
            "key": [
              {
                "id": "T_ESC",
                "text": "ESC",
                "nextlayer": "numeric"
              },
              {
                "id": "K_E",
                "text": "e"
              },
              {
                "id": "K_U",
                "text": "u"
              },
              {
                "id": "K_I",
                "text": "i"
              },
              {
                "id": "K_O",
                "text": "o",
                "pad": ""
              },
              {
                "id": "K_A",
                "text": "a",
                "pad": "50"
              },
              {
                "id": "K_HYPHEN",
                "text": "-"
              },
              {
                "id": "K_SLASH",
                "text": "/"
              },
              {
                "id": "K_COMMA",
                "text": ","
              }
            ]
          },
          {
            "id": 2,
            "key": []
          },
          {
            "id": 3,
            "key": []
          }
        ]
      },
      {
        "id": "numeric",
        "row": [
          {
            "id": 1,
            "key": [
              {
                "id": "K_NP2",
                "text": "Dn",
                "nextlayer": "default",
                "layer": "rightalt"
              },
              {
                "id": "K_NP5",
                "text": "Ct",
                "nextlayer": "default",
                "layer": "rightalt"
              },
              {
                "id": "K_NP8",
                "text": "Up",
                "nextlayer": "default",
                "layer": "rightalt"
              }
            ]
          }
        ]
      }
    ],
    "displayUnderlying": false
  }
}

Why is giving error? What is the remedy?

The bullet before the first any() statement in my previous message just now typed will be + (plus) sign.

It would help us if you also included a copy of the specific compilation error that you’re seeing.

The K_ESC key identifier is causing the problem here, I think. KeymanWeb compiler is expecting the key to produce a value but because it is reserved, it is getting confused about it.

Try using the $keymanonly compile target so that the mobile (web-based) keyboard compiler doesn’t attempt to compile it:

+ [T_ESC] > dk(dead1)
$keymanonly: + [K_ESC] > dk(dead1)

(So my original post was not quite right here, because I forgot that you just can’t use K_ESC on a touch keyboard, as the Escape key is reserved. To be honest, using keys such as Escape is not typically recommended, even on desktop devices, because Escape is a system key with system-reserved behaviours :slight_smile: ).