---
title: "ToolStripMenuItem and KeyPress or KeyDown event"  
description: "ToolStripMenuItem and KeyPress or KeyDown event"  
author: "Anonymous User"  
published: 2014-01-28  
updated: 2014-01-28  
canonical: https://www.mindstick.com/forum/1892/toolstripmenuitem-and-keypress-or-keydown-event  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# ToolStripMenuItem and KeyPress or KeyDown event

I am using ToolStripDropDownButton and dynamically adding menu [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) as below:

toolStripDropDownButton1.DropDownItems.Clear();

ToolStripMenuItem item1 = new ToolStripMenuItem("Item1");

toolStripDropDownButton1.DropDownItems.Add(item1);

ToolStripMenuItem item2 = new ToolStripMenuItem("Item2");

toolStripDropDownButton1.DropDownItems.Add(item2);

I would like to [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) the selected [menu item](https://www.mindstick.com/forum/339/highlighting-the-menu-item) when the Delete key is pressed. But the ToolStripMenuItem doesn't have KeyPress or KeyDown event.

I am using [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010 and .NET 4.0. Any [suggestions](https://www.mindstick.com/blog/299486/how-to-write-for-your-audience) on how to achieve this [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery)?

## Replies

### Reply by Pravesh Singh

Hi Jay,

The enclosing ToolStrip gets the key events so you can handle it there with something like:

```
toolStripDropDownButton1.KeyDown += (s, e) =>{    if (e.KeyCode ==Keys.Delete)    {        foreach (var item in ((ToolStrip)s).Items.OfType<ToolStripMenuItem>())        {            if(item.Selected)            {               
((ToolStrip)s).Items.Remove(item);                break;            }        }    }};
```


---

Original Source: https://www.mindstick.com/forum/1892/toolstripmenuitem-and-keypress-or-keydown-event

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
