# Getting an event for selection of area

**URL:** <https://pdfjs.community/t/getting-an-event-for-selection-of-area/3077>\
**Category:** Technical Support\
**Created:** [January 15, 2024, 10:41pm UTC](https://pdfjs.community/t/getting-an-event-for-selection-of-area/3077 "2024-01-15T22:41:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/david/32/1732_2.png) [@david](https://pdfjs.community/u/david)\
**Post date:** [January 15, 2024, 10:41pm UTC](https://pdfjs.community/t/getting-an-event-for-selection-of-area/3077/1 "2024-01-15T22:41:54Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer

**PDF.js Express Version**

| | version |
| --- | --- |
| UI version | ‘8.7.0’ |
| Core version | ‘8.7.4’ |
| webviewer.min.js | ‘8.7.4’ |

**Detailed description of issue**  
When in selection mode in the viewer, you can draw a box around an area of the pdf. How do I get an event for when this happens along with the coordinates of the selection rectangle? I’ve searched the site and combed the documentation and haven’t been able to find anything.

![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/4/487faee23e4e1ee06df9e1ca8883ff274edb58c8.png)

**Expected behaviour**  
An easy-to-find, documented event.

**Does your issue happen with every document, or just one?**  
All

**Link to document**  
N/A

**Code snippet**  
N/A

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [January 16, 2024, 6:23pm UTC](https://pdfjs.community/t/getting-an-event-for-selection-of-area/3077/3 "2024-01-16T18:23:04Z")

</div>

Hello david,

Thank you for raising this,

You can get the area by listening to the mouseLeftDown and mouseLeftUp events like so

```javascript
const {documentViewer, Tools} = instance.Core
documentViewer.addEventListener("mouseLeftDown", (e)=>{
   const startLocation = documentViewer.getTool(Tools.ToolNames.EDIT).getMouseLocation(e);
})

documentViewer.addEventListener("mouseLeftUp", (e)=>{
   const endLocation = documentViewer.getTool(Tools.ToolNames.EDIT).getMouseLocation(e);
})

```

Best regards,  
Tyler
