This blog post contains outdated information.
The cited code snippets may be workarounds, and be part of the official API in the meantime.
JavaScript: Removing TextFields on Backspace and Delete
By default, text fields in the TX Text Control HTML5-based editor are not editable or deletable by users. Using the JavaScript API, developers can handle Backspace and Delete key events to programmatically remove text fields at any cursor position relative to a field boundary.

Using the Java
We received many requests last week regarding text fields and how to remove them programmatically - specifically using the Backspace and Delete keys. By default, fields are not editable and deletable. The following code snippet shows how to remove the field at the current input position when the user is pressing the Backspace or Delete key. This code also works, if these keys are pressed at the beginning or the end of a field in order to remove it.
window.onload = function () {
// attach keyDown event
document.addEventListener("keydown", keyDownHandler, false);
};
function keyDownHandler(e) {
var keyCode = e.keyCode;
// set fields to editable
TXTextControl.textFieldsEditable = true;
// if DELETE or BACKSPACE
if (keyCode == 8 || keyCode == 46) {
TXTextControl.getTextFields(function (e) { // get field at input positions
if (typeof e !== 'undefined' && e.length > 0) { // if array is defined
// remove the field at the input position
TXTextControl.removeTextField(e[0], false);
}
}, true);
}
}
Happy coding!
Also See
This post references the following in the documentation:
- TXText
Control. Server Text Control Class
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
Using the Document Editor in SPA Applications using the removeFromDom Method
This article shows how to use the removeFromDom method to remove the Document Editor from the DOM when it is no longer needed. This is useful when the Document Editor is used in a Single Page…
Sneak Peek 31.0: Customizing the Context Menu of the ASP.NET Document Editor
The online Document Editor of TX Text Control .NET Server 31.0 provides a fully customizable context menu. The context menu contents can be accessed through a new contextMenuOpening event that…
TXTextControl.Web: Creating a Custom ButtonBar using the InputFormat Class
TX Text Control X18 implements the InputFormat class in the JavaScript API that enables developers to build custom button bars.
New JavaScript API Calls for Typical MailMerge Tasks
This article shows how to use the improved JavaScript API for typical MailMerge tasks such as inserting merge blocks.
ASP.NETCollaborationDocument Editing
The Future of Document Collaboration
TX Text Control X16 adds MS Word-compatible track changes for asynchronous document red lining and contract negotiation. The browser-based editor enables multi-author document sharing workflows,…
