How do I make an Capslock Validator?

Get help using Construct 2

Post » Tue Jun 16, 2015 6:13 am

How do I make an action to detect if the capslock key is activated or no? Thanks in advance.
Liked something I say?
Tip. My Bitcoin address: 1PLaeKmXQ8vEdGGJqXMq3KyB8hxeddxeSv
B
26
S
8
G
4
Posts: 336
Reputation: 4,050

Post » Tue Jun 16, 2015 10:51 am

Thats real a problem. Javascript so also construct can only check capslock, when you press another key.
Because it only can check keycodes.

This would be look like this in javascript, you see you cant directly:
Code: Select all
$('#example').keypress(function(e) {
    var s = String.fromCharCode( e.which );
    if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) {
        alert('caps is on');
    }
});
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
11
S
4
G
1
Posts: 158
Reputation: 1,328


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests