Jump to content

how to detect capslock?


12p

Recommended Posts

Posted

I wish it was that easy. I wouldn't need to bother checking my local variable for caps.

But characters delivered from input are always in lower case.

Posted

Because it doesn't serve my purpose if the client has capslock enabled in his keyboard BEFORE joining a server, for obvious reasons.

Now, is it possible or not? Maybe I'm missing a function here?

Posted

Maybe this will help ?

addEventHandler ( 'onPlayerJoin', root, 
function ( ) 
triggerClientEvent ( source, 'Check', source ) 
 end 
) 
  
---Client 
addEvent('Check', true ) 
addEventHandler ('Check', root, 
function ( ) 
if getKeyState( "capslock" ) == true then 
outputChatBox(getPlayerName(localPlayer)..'His CapsLocks Are Active ', 255, 255, 0 ) 
elseif getKeyState ( "capslocks") == false then 
outputChatBox(getPlayerName(localPlayer)..'His CapsLocks Are Not Active ', 255, 255, 0 ) 
  end 
end 
) 
Posted

@SuperCroz

I didn't try using that event before... Tried now.

Unfortunately, it din't work. Directly checking input only delivers lower case :(

@Max

I appreciate your intention, but if you don't know what you talk about then don't try to help me in first place. That code won't work because, as I implied in my previous post: since getKeyState only detects whether a key is pressed or not, it would only help when the player presses capslock after joining a server.

Posted

As far as i know it's not possible to check it with pure LUA ( aka LUA suck's a bit ). For this you would need to use Window's API's on the input handle Level , so this is more like up to the mod's to integrate a function inside MTA's DLL. Bk you will not be able to host a modified MTA version.

Posted
Oh, too bad.

I guess I have a suggestion for MTA now...

yes , exactly it will Only work when it's pressed , if you you want to detect it witout press and unpress you Can't

Posted
yes , exactly it will Only work when it's pressed , if you you want to detect it witout press and unpress you Can't

wow thanks for the bit of information someone else already told me

If any moderator comes, I ask to close this topic. My problem has its answer already, thanks to bandi94.

Posted
I wish it was that easy. I wouldn't need to bother checking my local variable for caps.

But characters delivered from input are always in lower case.

How do you mean?

Posted
Is there a way to do it without getKeyState?

getKeyState? check continuously if the key is active

| or cancel uppercase messages as this.

if not string.find(string.lower(text), text, 1, true) then outputChatBox("#E7DBADCaps Lock desativado.",source, 255, 255, 255, true) cancelEvent() return end 

Posted

Thanks, but that does no help at all. You clearly don't understand the question I made on this topic.

I already how to deal with lower and upper case; all I wanted was to know whether the client had capslock ENABLED IN HIS KEYBOARD; not whether the player pressed it.

So...

If any moderator comes, I ask to close this topic. My problem has its answer already, thanks to bandi94.

Please, don't bother replying, any of you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...