0

I want to handle the CapsLock and NumLock key using angular or node js. So is there any way to do that?

I have tried the dispatchEvent but it does not working.

  • Even if you could (which I doubt), it's hard to imagine a use case for this that wouldn't be surprising and irritating to users. Maybe you have one, but it's hard to imagine... – T.J. Crowder Mar 27 '23 at 11:30
  • Angular runs in a browser, and browsers certainly don't have the ability to do this for security reasons. Make sure you're clear on where your code is running - it sounds like you want a web app to take over control of the user's keyboard, which is forbidden, but if you're building an app in node to distribute some other way, it may be possible. – Sasha Kondrashov Mar 27 '23 at 11:32
  • Please provide a more detailed explanation of what you need to do. You've tagged [tag:electron] -- is this in an Electron app? It **may** be possible in the server part of that. Almost certainly not in the browser part where the tags [tag:angular] and [tag:jquery] would apply. – T.J. Crowder Mar 27 '23 at 11:36
  • Yes, it's an electron app. I want to check that does my CapsLock is on or not. if not then I want to on it when my app loads or refreshes. – selenagomez Mar 27 '23 at 11:52
  • Just FWIW, as a user, if an app turned CapsLock on every time I went into it, I'd immediately uninstall the app. Instead, can't you treat input as case-insensitive, showing it in all caps (if that's really appropriate -- note it's harder to read all caps than properly capitalized text). – T.J. Crowder Mar 27 '23 at 11:57
  • @T.J.Crowder , I do not have any input to take and show in capslock, I have to enable the capslock for the other things. – selenagomez Mar 27 '23 at 12:03
  • There's no need for mystery: ***What*** "other things"? – T.J. Crowder Mar 27 '23 at 12:05
  • If you want make all letter uppercase in an input, you can use, css uppercase, or js 'string'.toUpperCase(). But if you really need to control the keyboard device, i think the only way is to use electron bridge, to be abble to make system calls, or c++ implementations – Riheldo Melo Mar 27 '23 at 12:05
  • @T.J.Crowder There is a device I am connecting, which bulb a light so as I checked when I have a capslock on it bubbled the light. And when the capslock is off it does not show any light. so I want to keep the capslock on. – selenagomez Mar 27 '23 at 12:10
  • https://stackoverflow.com/a/34277417/3910390 – Penguin Mar 28 '23 at 07:53
  • @Penguin - OP wants to **set** the state, not read it. – T.J. Crowder Mar 28 '23 at 08:00

0 Answers0