capslock

How can I find the state of NumLock, CapsLock and ScrollLock in .net?

戏子无情 提交于 2019-12-17 05:04:22
问题 How can I find the state of NumLock, CapsLock and ScrollLock keys in .net ? 回答1: Import the WinAPI function GetKeyState [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] public static extern short GetKeyState(int keyCode); and then you can use it like that bool CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0; bool NumLock = (((ushort)GetKeyState(0x90)) & 0xffff) != 0; bool ScrollLock = (((ushort)GetKeyState(0x91)) &

How do you tell if caps lock is on using JavaScript?

我只是一个虾纸丫 提交于 2019-12-16 20:13:08
问题 How do you tell if caps lock is on using JavaScript? One caveat though: I did google it and the best solution I could find was to attach an onkeypress event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down. If it wasn't, therefore caps lock must be on. This feels really dirty and just... wasteful - surely there's a better way than this? 回答1: Found this interesting.... You can give it a try.. function isCapslock(e){

keyDown event is not fired for Capslock in Mac

眉间皱痕 提交于 2019-12-12 13:41:44
问题 CHROME (52): When turning caps lock ON - only keydown is fired (no event in keyUp or keyPress) When turning caps lock OFF - only keyup is fired (no event in keyDown or keyPress) FIREFOX (46): Only keyDown event is fired for both caps lock ON & OFF (no keyUp or keyPress) I've read about the keyCodes and events here http://www.quirksmode.org/js/keys.html and in MDN here https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode, aaaand here http://unixpapa.com/js/key.html But none

How can I check if capslock is on without waiting for the user to type character using JavaScript?

醉酒当歌 提交于 2019-12-12 10:46:07
问题 Gmail shows an icon in Chrome when the user has capslock on and focuses on the password field, how are they able to do that? There are many related question to this, but no one seem to know how to do it without user input, like: How do you tell if caps lock is on using JavaScript? 回答1: Nevermind, this is a native function of the Chrome browser when focusing on password field, clever! 来源: https://stackoverflow.com/questions/10680935/how-can-i-check-if-capslock-is-on-without-waiting-for-the

How to consume CAPS-LOCK event on MacOS

戏子无情 提交于 2019-12-11 17:22:50
问题 I am trying to remap CAPS-LOCK. I can successfully detect CAPS-LOCK key-down/up events using CGEventTap . However, I am unable to consume them. (OTOH I am able to consume ordinary key-down/up events). The below code excerpt illustrates this: @implementation Intercept - (BOOL) tapEvents { _eventTap = CGEventTapCreate( kCGHIDEventTap, // kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, CGEventMaskBit( NSEventTypeKeyDown ) | CGEventMaskBit( NSEventTypeFlagsChanged ) |

Way to turn on keyboard's caps-lock light without actually turning on caps-lock?

旧街凉风 提交于 2019-12-11 02:33:35
问题 I'm writing a program that uses caps-lock as a toggle switch. It would be nice to set the LED of the key to show that my program is on or off, like the capslock key does naturally. I know that I could just SendInput('Capslock'); or whatever to actually turn caps-lock on and off. But my app is a typing program, and I don't want to have to deal with translating the all-caps keys that turning it on would give me into their lower/upper cases. I might go that route eventually, but not for this

How to Detect Caps Lock in a Vimrc Function

别说谁变了你拦得住时间么 提交于 2019-12-10 03:14:34
问题 When editing code in Vim, I will often use caps lock when writing stuff in ALL CAPS. However, I often forget to turn off caps lock when I'm done with the capitalized portion. This causes no end of pain (since, ie, j moves down, but J joins the current line with the line below). Usually, I want to turn off caps lock when I exit insert mode. How can I add something to my .vimrc so that it will either turn caps lock off when exiting insert mode? Alternately, how could I add something to my

转:Windows下交换CapsLock和左ctrl

柔情痞子 提交于 2019-12-09 15:33:04
Windows下交换CapsLock和左ctrl HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout中添加Scancode Map二进制项,内容为 0000 00 00 00 00 00 00 00 00 0008 03 00 00 00 1D 00 3A 00 0010 3A 00 1D 00 00 00 00 00 注销或者重启一下就能看到效果了 来源地址: https://blog.csdn.net/bnanoou/article/details/51187673 来源: https://www.cnblogs.com/zhzhlong/p/12011156.html

Does anyone know where OSX stores the settings in System Preferences > Keyboard > Modifier Keys?

一个人想着一个人 提交于 2019-12-07 13:04:38
问题 I'm apparently not the only one who wants to know (How can I change modifier keys in "System Preferences > Keyboard > Modifier Keys..."). I've tried watching the System Preferences app with dtruss, but that doesn't seem to be possible on 10.10.3 (which is what I'm on right now), and I'm not even sure that that would be at all useful if System Preferences is just getting settings from cfprefsd. Watching cfprefsd with dtruss doesn't seem to catch the relevant file access. Does anyone know of an

How to simulate Caps Lock keystroke with CGEventCreateKeyboardEvent in OS X

扶醉桌前 提交于 2019-12-06 10:29:47
问题 Has anyone had any luck simulating Caps Lock keystroke with CGEventCreateKeyboardEvent on OS X? Basically I have tried alphabetic character and alphanumeric character okay but Caps Lock. Hopefully, I would like to simulate Caps Lock keystroke to trun on/off the LED. I don't know what problem is for my test code. Has anyone had experinces for this? #include <stdio.h> #include <ApplicationServices/ApplicationServices.h> main() { bool wasCapsLockDown = CGEventSourceKeyState