MSEdgeExplainers

HTML Attribute to Allow/Disallow Handwriting Input (i.e., "ink to text")

Outdated

As of November 14th 2024, this explainer has been replaced with HandwritingIntentCSSValue which proposes a new keyword for the touch-action CSS attribute.


Consider all sections required unless otherwise noted.

Authors: Rahul Arakeri, Adam Ettenberger, Ben Mathwig, Jenny Ma

Status of this Document

This document is a starting point for engaging the community and standards bodies in developing collaborative solutions fit for standardization. As the solutions to problems described in this document progress along the standards-track, we will retain this document as an archive and use this section to keep the community up-to-date with the most current standards venue and content location of future work and discussions.

Introduction

A new web standard mechanism is needed to indicate whether an element or its subtree should allow user agent handwriting input.

Authors may need to exclude an editable text element from handwriting input for UX or app behavioral reasons.

This will be useful for developers of text-editing apps, drawing apps, or apps with their own stylus-optimized input handling.

Goals

Give authors granular per-document and per-element control over which content should (dis)allow handwriting input.

Non-Goals

Use Cases

Some scenarios where a website or application may want to disable handwriting input:

example of handwriting input inserting the text "Hello World"

Proposed Solution

Introduce a new HTMLElement HTML+IDL attribute which allows authors to specify whether an element should (dis)allow handwriting input.

Keywords and States

The handwriting attribute is an enumerated attribute with the following keywords and states:

Keyword State Brief Description
false false The element will not allow handwriting input even when supported by the user agent.
true true The element will allow handwriting input if supported by the user agent.
(the empty string) true The element will allow handwriting input if supported by the user agent.

The attribute's missing value default is the default state and the attribute's invalid value default is the true state.

Computed Value

The computed handwriting value of a given element can be determined by running the following steps:

  1. If element's handwriting content attribute is in the false state, return "false".
  2. If element's handwriting content attribute is in the default state, element has a parent element, and the computed handwriting value of element's parent element is "false", then return "false".
  3. Return "true".

HTML Attribute

All HTML elements may have the handwriting attribute set. See "Keywords and States" for accepted values.

Syntax

<textarea></textarea>                       <!-- the computed handwriting value is true -->
<textarea handwriting></textarea>           <!-- the computed handwriting value is true -->
<textarea handwriting=""></textarea>        <!-- the computed handwriting value is true -->
<textarea handwriting="true"></textarea>    <!-- the computed handwriting value is true -->
<textarea handwriting="false"></textarea>   <!-- the computed handwriting value is false -->

<div handwriting="false">
  <textarea></textarea>                     <!-- the computed handwriting value is false -->
  <textarea handwriting></textarea>         <!-- the computed handwriting value is true -->
  <textarea handwriting=""></textarea>      <!-- the computed handwriting value is true -->
  <textarea handwriting="true"></textarea>  <!-- the computed handwriting value is true -->
  <textarea handwriting="false"></textarea> <!-- the computed handwriting value is false -->
</div>

IDL Attribute

The HTMLElement handwriting attribute will be exposed as an IDL attribute to JavaScript with the type DOMString, similar to the writingsuggestions or contenteditable attributes.

When getting the IDL attribute, the computed handwriting value will be returned, see the "Computed Value" section for details.

When setting the IDL attribute, the HTML attribute is updated to the assigned string value.

Syntax

var element = document.createElement("div");
console.assert(typeof(element.handwriting) == "string");
console.assert(!element.hasAttribute("handwriting"));
console.assert(element.handwriting == "true");

element.handwriting = "true";
console.assert(element.getAttribute("handwriting") == "true");
console.assert(element.handwriting == "true");

element.handwriting = false;
console.assert(element.getAttribute("handwriting") == "false");
console.assert(element.handwriting == "false");

element.handwriting = "unexpected";
console.assert(element.getAttribute("handwriting") == "unexpected");
console.assert(element.handwriting == "true");

Privacy and Security Considerations

Privacy

Since the proposed HTML+IDL attribute should not interact with other HTML or IDL attributes, DOM properties, CSS properties, or JavaScript APIs in an interesting way, and the attribute doesn't reflect whether a user agent supports or has enabled handwriting input, it shouldn't be possible to use this for fingerprinting. As of writing this, I'm not aware of any way the proposed attribute could be used towards nefarious means since it's merely a hint for the browser to (dis)allow handwriting input and the handwriting state doesn't expose anything about the user nor their device.

Security

There are no known security impacts of the features in this specification.

Alternative Solutions

The proposal is for this to be an HTML+IDL attribute.