Detect which Enter key is pressed

4

1

Is there a way to tell which Enter key was pressed? Does that require a low-level driver or something similar? Does the OS know which Enter was pressed?

I'm on Windows and I tried Carnac but it only tells me if Enter was pressed or not.

Saravanabalagi Ramachandran

Posted 2018-06-25T10:50:58.267

Reputation: 420

It looks like this is possible with programming for example https://stackoverflow.com/questions/8059177/distinguish-between-normal-enter-and-the-number-pad-enter-keypress and I suspect this means Python also has a similar method to differentiate too but I don't have time to verify but perhaps this will give you a starting point for a Python solution to play with and research as such https://stackoverflow.com/questions/33863921/detecting-a-keypress-in-python-while-in-the-background . . . Tag me back when/if you get an answer, I like this question.

– Pimp Juice IT – 2018-06-25T11:57:51.320

Answers

0

If you're referring to the number pad, scripts in AutoHotkey will trigger/detect separately for Enter and for NumPadEnter

Depending on what you want to do, you can trigger on these separately but allow the keystroke to go through to the original application by utilizing a tilde in front of the hotkey definition, and then take a follow-up action on the side (in parallel) with the keystroke being sent to the application (send a message, log somewhere, etc.)

JJohnston2

Posted 2018-06-25T10:50:58.267

Reputation: 1 341

0

As far as I know, both enter keys have the same scan code (VK_RETURN). I think that the numpad key can be determined by checking the lParam from e.g. a WM_KEYDOWN message.

Numpad keys are probably going to set the "extended" bit (bit 24) to a value of 1. So an AND operation (lParam & x1000000) would test that bit.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646280(v=vs.85).aspx

That is how Windows sees it, but it may not be exposed in many hotkey-style programs.

Yorik

Posted 2018-06-25T10:50:58.267

Reputation: 2 956