ID:502426
 
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.
I tried a search to see what I could dig up on this and couldn't find anything. Basically what I'm looking for is a simple built-in function that checks whether or not the user has Capslock active.

For my purposes, this type of function would allow me to set macros for players to type their names into our map-based name input HUD:



I know that the key+Shift check will already work for typing capital letters, but not having Capslock function for this as well would be weird.

I'm not sure what other uses a simple check like this might have (or how simple it would really be for you to implement), but there it is. Thanks!
For the time being, you can use javascript to detect this. This is what I've done for similar naming systems.
I requested this a long time ago, though I believe it was before the trackers.
This would be useful.
Could use one for NumLock too.
scroll lock pls.
I'm currently working on a strictly screen object/image chat system, think of a game with only a single map element, and I was sad to realize caps-lock isn't detected among other things like mouse-wheel scrolling. (Seriously it detects mouse wheel clicking but not scrolling...)
Bump. This seems like a trivial thing but I think having basic key detections for the entire keyboard is important.

I don't really know what would go into implementing this, but from an outsider looking in it seems simple.
I'd love to see support for caps lock, scroll lock, num lock, mouse scrolling and the whole bunch of it. Might as well unless there is some design flaw.

Nadrew mentioned javascript for a work around, this is definitely good to know but I still would like to see more native support.
I've never gotten javascript to detect capslock, then again I'm not really familiar with programming outside of DM- so integrating it was more of piecing stuff together and trial and error; even then, this stuff should be default in my opinion.
Yeah, this could be pretty useful so I'd like to see it added.
You could have a macro on the Capslock key to set a capslock variable to TRUE or FALSE, but that would only work if they have Capslock set to the default position defined in the game, if they press it while the window is active (can't detect inactive keystrokes), and it's just not possible to detect within the built-in engine right now; though, as Nadrew pointed out, you could use javascript.

+1 to make it a built in proc.
I agree with the native support but the javascript method is a quick workaround in the meantime.

Just some

event.keyCode //Numerical value for a key
event.shiftKey //bool value {tells if shift is held or not}


If the value of the keyCode is between 65 and 90, and you are not holding shift, it means capslock is active.

If the value of the keyCode is between 97 and 122, and you are holding shift, it means capslock is active.

If both of the above are false, capslock is not on.

Putting it into javascript:

var capsLockEnabled = false; //our variable to determine capsLock
keyCode = event.keyCode?event.keyCode:event.which; //who-joo-ja-voodoo
shiftKey = event.shiftKey?event.shiftKey:((keyCode == 16)?true:false); //voodo-crap to determine if shift is being held or not.
if(keyCode == 20) { //20 = capslockkey, so lets toggle it
capsLockEnabled = !capsLockEnabled; //toggles capslock
}
if(((keyCode >= 65 && keyCode <= 90) && !shiftKey)||((keyCode >= 97 && keyCode <= 122) && shiftKey)) { //if capslock is enabled
capsLockEnabled = true; //lets enable capslock
} else { //otherwise
capsLockEnabled = false; //BAM, disabled.
} //:)


In response to Ssj4justdale
If you are going to use JavaScript, then checking whether shift or caps lock is being used is mostly irrelevant, because you can just check if the character values returned are uppercase or lowercase.

The only time when you would care to know the difference is if you wanted to warn the user about caps lock being on, but in JavaScript, you can't actually know the state of the key until they start typing something.

Ironically, when it comes to input, JavaScript currently gets you closer to the hardware than DM does, although it still has some limitations. For example, you can't tell the difference between Enter and Numpad Enter, and you can't properly tell if one of the right modifier keys is being held at the same time as the corresponding one on the left. There is some kind of bias towards the left modifiers, for some reason.
In response to Multiverse7
Multiverse7 wrote:
If you are going to use JavaScript, then checking whether shift or caps lock is being used is mostly irrelevant, because you can just check if the character values returned are uppercase or lowercase.

The only time when you would care to know the difference is if you wanted to warn the user about caps lock being on, but in JavaScript, you can't actually know the state of the key until they start typing something.

Ironically, when it comes to input, JavaScript currently gets you closer to the hardware than DM does, although it still has some limitations. For example, you can't tell the difference between Enter and Numpad Enter, and you can't properly tell if one of the right modifier keys is being held at the same time as the corresponding one on the left. There is some kind of bias towards the left modifiers, for some reason.

I'm aware that this won't kick in until they start typing, but it checks if capitalization is true and if shift is true, then caps lock is off. If capitalization is true and shift is true, capslock is on. If capitalization is false and if shift is false, caps lock is off.

Aside from that, it's still very limited to when the user starts typing
The only problem I have with JS work arounds is that JS can be turned off. Depending on what you're using it for the workaround can be integrated regardless and just not a feature for those that have it off. Then there are the moments when you need a JS work around for something in the core of your application. Now you can't accept users with JS disabled or you have to find some other funky work around for them. =/

EDIT: I need to really start looking into creating DLLs. Quick question- Is making calls to dlls in DM slow?
In response to Lavitiz
Lavitiz wrote:
The only problem I have with JS work arounds is that JS can be turned off. Depending on what you're using it for the workaround can be integrated regardless and just not a feature for those that have it off. Then there are the moments when you need a JS work around for something in the core of your application. Now you can't accept users with JS disabled or you have to find some other funky work around for them. =/

EDIT: I need to really start looking into creating DLLs. Quick question- Is making calls to dlls in DM slow?

Calls to a .dll is fast and efficient as long as the .dll doesn't have a memory leak(faulty programming practically).

The only issue with .dll's are that they are server side only and not client-side. So it'll be cool for sockets and such, just not finding stuff out about clients, like capslock detection and such :/
In response to Lavitiz
Lavitiz wrote:
The only problem I have with JS work arounds is that JS can be turned off. Depending on what you're using it for the workaround can be integrated regardless and just not a feature for those that have it off. Then there are the moments when you need a JS work around for something in the core of your application. Now you can't accept users with JS disabled or you have to find some other funky work around for them. =/

EDIT: I need to really start looking into creating DLLs. Quick question- Is making calls to dlls in DM slow?

Also, under most circumstances, the .dll will get the job done in an estimated 3x the speed BYOND does it. (I only tested it with strings and such, I could be mistaken on everything but definitely does get the job done faster)
Thanks for the info, Ssj4justdale! Informative as usual, haha. I didn't even think about the calls being client side. So caps lock detection is locked to js. T_T

Native support, please! If not for me, for Silk. :3
Lavitiz: Check out the tutorials forum on a relatively easy DLL tutorial if you want
Page: 1 2