# 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.

> **Note:** This article is outdated and may no longer be accurate.

- **Author:** Bjoern Meyer
- **Published:** 2018-10-24
- **Modified:** 2026-03-05
- **Description:** 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.
- **2 min read** (218 words)
- **Tags:**
  - ASP.NET
  - JavaScript
  - Release
  - Web Editing
- **Web URL:** https://www.textcontrol.com/blog/2018/10/24/javascript-removing-textfields-on-backspace-and-delete/
- **LLMs URL:** https://www.textcontrol.com/blog/2018/10/24/javascript-removing-textfields-on-backspace-and-delete/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2018/10/24/javascript-removing-textfields-on-backspace-and-delete/llms-full.txt

---

Using the JavaScript api, a document can be manipulated in the HTML5-based rich text editor. Version X15 already contains a solid number of classes and methods to fulfil common tasks. We are working on a huge update for this interface for version X16 where you will see many new classes and methods available. The ultimate goal is to provide a complete API comparable to the API that is useable with TXTextControl.ServerTextControl class.

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!

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Using the Document Editor in SPA Applications using the removeFromDom Method](https://www.textcontrol.com/blog/2024/09/02/using-the-document-editor-in-spa-applications-using-the-removefromdom-method/llms.txt)
- [Sneak Peek 31.0: Customizing the Context Menu of the ASP.NET Document Editor](https://www.textcontrol.com/blog/2022/08/25/sneak-peek-310-customizing-the-context-menu-of-the-aspnet-document-editor/llms.txt)
- [TXTextControl.Web: Creating a Custom ButtonBar using the InputFormat Class](https://www.textcontrol.com/blog/2020/03/20/creating-a-custom-buttonbar-using-the-inputformat-class/llms.txt)
- [New JavaScript API Calls for Typical MailMerge Tasks](https://www.textcontrol.com/blog/2020/03/19/new-javascript-api-for-typical-mailmerge-tasks/llms.txt)
- [The Future of Document Collaboration](https://www.textcontrol.com/blog/2018/10/22/the-future-of-document-collaboration/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [Build a Custom Backstage View in ASP.NET Core with TX Text Control](https://www.textcontrol.com/blog/2026/02/17/build-a-custom-backstage-view-in-aspnet-core-with-tx-text-control/llms.txt)
- [5 Document Workflows You Can Automate With JavaScript Rich Text Editor](https://www.textcontrol.com/blog/2026/01/14/five-document-workflows-you-can-automate-with-javascript-rich-text-editor/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [PDF/UA vs. PDF/A-3a: Which Format Should You Use for Your Business Application?](https://www.textcontrol.com/blog/2025/10/24/pdf-ua-vs-pdf-a-3a-which-format-should-you-use-for-your-business-application/llms.txt)
- [Validating PDF/UA Documents in .NET C#](https://www.textcontrol.com/blog/2025/10/21/validating-pdf-ua-documents-in-dotnet-csharp/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [High-Performance Text Replacement in Large DOCX Files using C# .NET](https://www.textcontrol.com/blog/2025/07/30/high-performance-text-replacement-in-large-docx-files-using-csharp-dotnet/llms.txt)
- [Document Viewer 33.2.1 Released: New Event and Bug Fixes](https://www.textcontrol.com/blog/2025/07/30/document-viewer-33-2-1-released-new-event-and-bug-fixes/llms.txt)
- [Upcoming Support for PDF/UA Compliance and Tagged PDF Generation in Version 34.0](https://www.textcontrol.com/blog/2025/07/24/upcoming-support-for-pdf-ua-compliance-and-tagged-pdf-generation-in-version-34-0/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Add JavaScript to PDFs with TX Text Control in C# .NET: Time-Based Alerts Made Easy](https://www.textcontrol.com/blog/2025/06/13/add-javascript-to-pdfs-with-tx-text-control-in-c-dot-net-time-based-alerts-made-easy/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Introducing DS Server 4.0: Linux-Ready and Container-Friendly](https://www.textcontrol.com/blog/2025/04/30/introducing-ds-server-4-linux-ready-and-container-friendly/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [DS Server 3.5.0 Released](https://www.textcontrol.com/blog/2024/09/24/ds-server-3-5-0-released/llms.txt)
