How to record good typing patterns
Recording qualitative typing patterns is the basis for effective authentication with typing biometrics as a passive second factor
However, common pitfalls can easily lead you to record patterns that will result in low matching scores and higher False Rejection Rates (the metric that shows how often the system fails to identify an authorized user).
The good news is that all of these mistakes can be avoided by recording typing patterns correctly. To do that, you simply need to avoid the following all-too-common pitfalls:
-
When recording same text patterns (type = 1), make sure you get typing patterns on the same textid (a unique identifier of the text), i.e., on the text-to-type and not the actual text being typed. You can achieve this by sending the text-to-type to the text param. If text is not provided, the recorder will generate its own textid based on the actual typed text. However, consider the case when users are asked to type the same sentence multiple times. How many of them will manage to type without typos so that you get consistent patterns on the same textid? To allow users to type naturally, you need to accept some typos. To do that, get the pattern on the textid of the same text:
var
tdna
=
new
TypingDNA();
var
textToType
=
'This is my text to type'
;
var
tp
=
tdna.getTypingPattern({
type
:
1
,
text
: textToType });
That brings us to a second suggestion, when recording same text patterns: allow typos, but make sure at least 93% of the typed text matches the type-to-text:
var
textToType
=
'This is my text to type'
;
var
typedText
=
document
.getElementById(
'inputText'
).value;
var
isValid
=
true
;
if
(typedText.length / textToType.length) <
0.8
{
isValid
=
false
;
}
if
(
compareTexts
(textToType, typedText) <
0.8
{
isValid
=
false
;
}
function
compareTexts
(t1, t2) {
var
dt1
=
t1.split(
' '
);
var
dt2
=
t2.split(
' '
);
var
total2
=
0
;
var
total1
=
0
;
for
(
var
i
in
dt2) {
total2 += (dt1.indexOf(dt2[i]) >
-1
)
?
1
:
0
;
}
for
(
var
i
in
dt1) {
total1 += (dt2.indexOf(dt1[i]) >
-1
)
?
1
:
0
;
}
var
total = (dt1.length > dt2.length) ? dt1.length : dt2.length;
var
length = (dt1.length > dt2.length) ? dt1.length : dt2.length;
return
total / length;
}
-
Check for null typing patterns before sending them to the Authentication API service — either for enrollment or verification. This can be done easily:
var
textToType
=
'This is my text to type'
;
var
tp
=
tdna.getTypingPattern({
type
:
1
,
text
:
textToType });
var
isValid
=
true;
if
(!tp) {
isValid =
false;
}
- If you want to record multiple typing patterns in the same view, the property targetId of the method getTypingPattern will come to the rescue, letting the recorder know where to collect keystrokes from. You might want to do this if you wish to perform the enrollment step in one view, collecting two or more patterns of the same text.
var
textToType
=
'This is my text to type'
;
var
tp1
= tdna.getTypingPattern({
type
:
1
,
text
:
textToType,
targetId
:
'inputText1'
});
var
tp2
= tdna.getTypingPattern({
type
:
1
,
text
:
textToType,
targetId
:
'inputText2'
});
- You may want to record one typing pattern from multiple inputs, e.g., getting the pattern for the username and password. In this case, the text-to-type will be the concatenated string between the typed username and the typed password. Notice that, in this use case, typos are not allowed. Otherwise, the user couldn’t log in. As such, registering the pattern on the typed text will always get the same textid.
var
username =
document
.getElementById(
'username'
).value;
var
password =
document
.getElementById(
'password'
).value;
var
tp =
tdna.getTypingPattern({
type
:
1
,
text
:
username + password });
- A suboptimal text length of the typed text can negatively influence the verification score. Our recommendation is the following:
-
- Same text solution: tweet-long texts of 30 characters
- Any text solution: 160 to 200 characters for enrollment; 120 to 140 for verification
Read more about the recommended Rules to create texts.
- Consider that mobile typing patterns are different from desktop patterns. They capture data differently, so matching between mobile and desktop patterns will not work correctly. However, they are recorded in the same manner, so nothing needs to be done on the front-end in this case. Learn more about how to handle mobile vs. desktop patterns in this article.
- If you would like to record patterns on secret text, like passwords, we don’t recommend you get patterns of type 2, as it records the typed characters as well. Use type 1 (same text) or type 0 (any text) instead, depending on your use case. Learn more about the different types here.
- Last but not least, don’t forget to instantiate the JavaScript recorder before performing any operation. Once this is done, usually when loading the page, any typing starts being recorded as a history of keystroke events.
var
tdna =
new
TypingDNA();
For more support, contact us at support@typingdna.com.