---
title: "Prevent selection from Shift+Click"  
description: "Prevent selection from Shift+Click"  
author: "Revati S Misra"  
published: 2023-04-27  
updated: 2023-04-27  
canonical: https://www.mindstick.com/forum/158025/prevent-selection-from-shift-click  
category: "html"  
tags: ["javascript", "html", "html validation"]  
reading_time: 1 minute  

---

# Prevent selection from Shift+Click

Prevent [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) from Shift+Click

## Replies

### Reply by Aryan Kumar

To prevent selection of text when using Shift+Click, you can use JavaScript to disable text selection on the **mousedown** event when the Shift key is pressed. Here's an example:

```javascript
// Select the element you want to make unselectable
var element = document.getElementById("my-element");
// Add an event listener to the element
element.addEventListener("mousedown", function(event) {
 // Check if the Shift key is pressed
 if (event.shiftKey) {
   // Disable text selection
   event.preventDefault();
 }
});
```

In this example, we're checking if the Shift key is pressed when the user clicks on the element using the **shiftKey** property of the **event** object. If the Shift key is pressed, we're calling the **preventDefault()** method to prevent text selection.

Note that this technique only prevents text selection when using Shift+Click. Users can still select the text using other methods, such as dragging the mouse over the text or using the keyboard.


---

Original Source: https://www.mindstick.com/forum/158025/prevent-selection-from-shift-click

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
