Andrew
Andrew

Reputation: 2539

Keypress in ASP.NET

Is it possible to detect keypresses without selecting anything on screen? I'm trying to make an online version of the Window's calculator. My searches so far have been fruitless; all I can find is how to detect keypresses in textboxes.

Upvotes: 2

Views: 937

Answers (3)

Rune FS
Rune FS

Reputation: 21742

Set the focus on a hidden input element and catch the keypresses with javascript.

Upvotes: 0

alexl
alexl

Reputation: 6851

You should use a javascript library to intercept the keypress in a browser.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038770

My searches so far have been fruitless; all I can find is how to detect keypresses in textboxes

That's because in a web application that's the best you could do. You can intercept key presses only on elements that have the focus.

Upvotes: 6

Related Questions