Skip to content

Same Finger N-gram

A same-finger n-gram (SFN) contains two or more actions assigned to the same resolved finger. The inclusive bigram query bi.sf.freq counts windows whose first and second actions include a pair assigned to the same finger. Repeating one physical key, such as ee, is included.

Take a look at the left middle finger’s column in QWERTY:

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys except
shift_leftLeft-hand keys

On this column:

  • ed (as in “tied”) is a same-finger bigram,
  • dec (as in “decor”) is a same-finger trigram,
  • c_d (as in “cod”) is a same-finger skipgram.

An action can be a press, hold acquisition, or hold release. A key that merely remains held is context rather than another action.

Same-finger metrics describe actions rather than a held posture. A simultaneous same-finger unigram compares only physical action keys within one event. A bigram compares every action key on the first event with every action key on the second. Sustained keys do not enter either metric. A matching window is counted once even when more than one key pair matches.

For an SFS between events A and C, a hold in both unchanged sustained contexts is removed before pairing because it did not move. Each endpoint then uses its action keys plus sustained keys present at only that endpoint. Since an acquired or released trigger is represented by the action set rather than the sustained context on that transition event, it remains in the comparison without turning a hold spanning the trigram into fictional same-finger motion.

Headline totals such as SFB and SFS1 count each bigram or trigram at most once, even if several physical pairs in that n-gram match the metric.

SFT exists only as a rhythm classification. Layouts Wiki does not publish a standalone SFT distance breakdown; the transient endpoint treatment above keeps steady holds from creating false SFTs.

Skip-two compares the endpoints of a four-event window, with two intervening keystrokes. Skip-three compares the endpoints of a five-event window, with three intervening keystrokes. The intervening events determine the separation but do not enter the endpoint classification. Both metrics use the same endpoint treatment as skip-one, including its treatment of transient sustained keys.

Each window contributes at most once to the headline count. Finger or distance predicates can refine the selection; those selections can overlap when one window contains several matching key pairs.

Off-home usage selects press actions on keys other than the resolved finger’s authored home key. Acquire, release, and sustained holds do not contribute.

The built-in Finger Usage metric view counts matching-key mass. For example, uni.keys(events:press,finger:LI,home:false).freq * 100 counts every matching left-index key, so a chord with several such keys contributes once for each key.

To count each matching event at most once per finger instead, use uni.(keys(events:press,home:false,finger:LI).count > 0).freq * 100. This boolean predicate selects the whole event once, regardless of how many keys match. Both queries divide by the complete weighted unigram-event population, including events that do not match the press filter. Neither the finger filter nor the off-home filter shrinks that denominator.

A same-finger bigram (SFB) is a bigram whose two actions use the same resolved finger. In some older sources, this metric is called same-finger utilization (SFU). The inclusive query bi.sf.freq counts both movement between different keys, such as QWERTY ed, and repeated use of one key, such as ee. The layout list’s builtin SFB column uses bi.sfdk.freq, which requires different physical keys and excludes ee.

Use bi.sk.freq for same-key bigrams and bi.sfdk.freq for same-finger bigrams on different keys. With alternate fingering, these need not partition the inclusive same-finger selection: the same physical key can resolve to different fingers in different contexts.

AKL Discord doctrine prioritizes SFB minimization as the most important goal of keyboard layout optimization. As a result, layouts from the AKL Discord tend to have lower SFBs than the vast majority of layouts created elsewhere.

The 2021 layout Whorf has 0.38% SFBs, the lowest achieved among ANSI layouts without introducing unreasonable row change patterns.

Layer activators · Keysets · Notes

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys
shift_leftLeft-hand keys except

Notes

KeysDetails
This key is absent from the original source.

For ANSI layouts that optimize the main 30 keys, quote, hyphen, and space without adjusting shift pairs, the minimum possible SFB ratio is 0.37%. This requires the following finger assignments:

o a '
e ; -
h b n
s f v
r l x
u i , . / (right pinky)
q w y p g c (left or right index)
t d j k z m (left or right index)

Note that Whorf is only 0.01 percentage points above this global minimum. Note also that this global minimum requires an unreasonably high-movement ui pinky; this demonstrates how optimizing for a single metric leads to worse overall result. Later popular layouts from the AKL Discord tend to range between 0.5% and 0.7% SFBs in exchange for better optimization on other metrics.

For reference, QWERTY has 3.97% SFBs, Dvorak has 1.88% SFBs, and Colemak has 0.95% SFBs.

Putting a letter on a thumb enables even lower SFBs. Night achieves 0.35% without sacrificing on scissors like Whorf:

Layer activators · Keysets · Notes

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys except
shift_leftLeft-hand keys

Notes

KeysDetails
This key is absent from the original source.

The lowest possible SFB ratio for a layout with one letter on thumb is 0.24%, with the following finger assignments:

e (left or right thumb)
o a '
y u -
t d k
s f v
h n m
i , . / (left or right pinky)
w p g ; c b (left or right index)
q r j l z x (left or right index)

As with the minimum SFB finger assignments for ANSI layouts, there is no obvious way to arrange these columns into a well-rounded layout. Any viable thumb alpha layout will need to adjust some of these columns to allow for optimization of other factors.

Adding more thumb keys does not decrease the minimum SFB ratio. With one more thumb key, for example, the minimum SFB ratio actually increases to 0.25%:

y u (left or right thumb)
o a '
e ; -
h b n
r l x
s z v
i , . / (left or right pinky)
q t d k m (left or right index)
w p f g j c (left or right index)

Further thumb keys similarly increase the minimum SFB ratio. The optimal number of letters on the thumb for SFB minimization is almost certainly exactly 1.

A same-key bigram (SKB) is a bigram in which both actions use the same physical key. It is also called same-finger repeat (SFR), or simply a repeat. The layout list’s SKB column uses bi.sk.freq.

For layouts without a magic or repeat key, total SKB% is fixed by the analysis corpus. The main point of comparison here is how SKBs are distributed across fingers, since the weaker fingers become fatigued more easily. Right pinky SKBs are a major problem on Dvorak, for example, since ss and ll are both very common in English:

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys
shift_leftLeft-hand keys except

The extent to which weak finger SKBs should be minimized varies with personal preference. The 2024 layout Kuntem, which has some devoted fans, loads up e and t on the pinkies. This results in 0.40% pinky SKBs from ee and tt:

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys except
shift_leftLeft-hand keys

This is still significantly better than Dvorak, and spread across two pinkies instead of one, but is relatively high in comparison to some other contemporary layouts. Graphite, for example, has only 0.05% pinky SKBs:

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys
shift_leftLeft-hand keys except

For layouts that place a letter on the thumb, it is commonly said that r on thumb is superior to e on thumb because rr is less common on ee, with the reasoning that even though thumbs are strong, they are relatively slow and easily fatigued compared to the other fingers at repeated motions. This is not universally accepted; some maintain that the thumbs are strong, fast, and hard to fatigue. Additionally, ee thumb repeats can be solved using a repeat key for someone who prefers lower repeats on thumb. (There are other reasons to prefer r on thumb; see the “Thumb Layouts” Google Doc, author unknown.)

For layouts with a repeat key (or a magic key that defaults to repeat), SKBs can be optimized to near zero. Whirl, for example, has 0.04% total SKBs thanks to the magic/repeat key on the right thumb:

Magic rules · Layer activators · Keysets · Notes

Magic rules

AfterBind
m
s
e
h
,

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left
MOsym

Keysets

shift_rightRight-hand keys
shift_leftLeft-hand keys except

Notes

KeysDetails
Repeat output

A same-finger skipgram (SFS) is a skipgram whose endpoint actions use the same resolved finger. The middle action establishes the separation but does not enter the endpoint comparison.

The inclusive query tri.ends.sf.freq counts repeated resolved fingers at the endpoints. The layout list’s builtin SFS column uses tri.ends.sfdk.freq, which additionally requires different endpoint keys. For example, QWERTY ehd matches both queries, while aha repeats the same physical key and is excluded from the builtin SFS column. Use tri.ends.sk.freq for same-key skipgrams, shown in the SKS column.

The SFS refinements in the Movement & Rhythm metric view’s Rhythm section use a broader endpoint condition: a repeated resolved finger or a repeated physical key. They include both examples within their respective rhythm categories, including same-key repeats with alternate fingering.

SFS is also called disjoint same-finger bigram (dSFB) in some older literature, especially among AKL Discord members.

A same-finger trigram (SFT) is a community term for a trigram typed with one finger. Layouts Wiki includes SFT patterns in its rhythm classification rather than publishing a standalone SFT statistic.

SFTs are common on legacy layouts such as QWERTY. Contemporary optimized layouts have a very low SFT ratio, so they are typically not an issue.

Higher order SFSs are also possible:

SFSn%=100×weighted matching (n+2)-event windowsweighted (n+2)-event windows\text{SFS}_n\% = 100 \times \dfrac {\text{weighted matching } (n+2)\text{-event windows}} {\text{weighted } (n+2)\text{-event windows}}

Here nn is the number of intervening events. SFS1 uses the original trigram population, SFS2 the four-event population, and SFS3 the five-event population. Projecting to endpoints does not replace that denominator.

Semi pioneered the use of SFS in keyboard layout analysis. In Semi’s analysis:

SFS%=∑i=0∞SFSi%⋅21i\text{SFS}\% = \sum_{i=0}^\infty \text{SFS}_i\%\cdot2^\frac1i

Layouts Wiki analyzes SFS1, skip-two (SFS2), and skip-three (SFS3).

Going back to the QWERTY example,

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys except
shift_leftLeft-hand keys

We call ed a 1u SFB, since the finger travels a distance of 1 unit to move from the e key to the d key.

Layer activators · Keysets

Layer activators

MOshiftwhen the next typed key is in shift_right
MOshiftwhen the next typed key is in shift_left

Keysets

shift_rightRight-hand keys except
shift_leftLeft-hand keys

The bigram ec takes longer to type than ed because the e and c keys are farther away from each other than the e and d keys. On ortholinear keyboards, the distance is exactly 2u. On row-staggered keyboards, the distance is 22+342\sqrt{2^2+\frac34^2}, or about 2.14u; we count this as a 2u SFB after rounding to the nearest 0.5u.