6

I need to define some event for Ctrl + .. What is the number of dot-key-code? I want something like these:

Enter is 13.

S is 83.

2 is 50.

According to this website.

What is it for .?

5

7 Answers 7

18

According to that same website, the .'s dot-key code is 190.

1
  • 1
    No problem, There's a search box on the website, here you can enter any character you want and it will give you the keycode, please don't forget to mark the correct answer by clicking the checkmark next to it. @stack Feb 3, 2016 at 10:48
6

According to the website, key-code for . is 190.

3
5

110 is also a dot. But from the numpad. Be aware/careful!

0
2

46 works for me

function logKeyCode(event){
   const keyCode = (event.which) ? event.which : event.keyCode;
    console.log('keyCode =',keyCode);
   if(keyCode==190 || keyCode==110 || keyCode==46){
      console.log('keyCode . detected');
      alert('keyCode . detected');
   }
  
}
<input type="text" onkeypress="logKeyCode(event)" />

5
  • This is actually a better solution. Jul 13, 2021 at 9:19
  • 2
    But this will accept 'n' also as 110 is code for 'n' Jul 14, 2021 at 4:45
  • 1
    What is the explanation? 46 is the ASCII code for dot (.). Why must it include three different values, 190, 110, and 46? What is the justification for it? What are those three magic numbers? Is one for the numeric keypad? We expect more than a code dump in a Stack Overflow answer. Nov 29, 2023 at 14:56
  • cont' - Please respond by editing (changing) your answer, not here in comments (but *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** without *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today). Nov 29, 2023 at 14:59
0

For Angular 8 it was 46 that worked for me

@HostListener("keypress", ["$event"]) onKeyPress(event) {
        let keyCode = parseInt(event.keyCode);

        if (keyCode == 46) {
        } else {
            event.preventDefault();
        }
    }
3
0

In my case 110 & 190 are the KeyCodes for .

This is an amazing website where you can find any keycode

https://www.toptal.com/developers/keycode

0

If you are customising a keyboard for your app, don't use any misleading keylabel...

KeyCode of the dot (.) character is 56.

For your custom keyboard...

<Key android:codes="56" android:keyLabel="." />

or

<Key android:codes="46" android:keyLabel="." />
2
  • 1
    this answers headline looks random can you try rephrase/elaborate it so it's more useful?
    – Xesenix
    Jun 25, 2019 at 20:33
  • Is 56 a typo? The ASCII code of "." is 46. And isn't it the character code, not the key code? Nov 29, 2023 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.