How can I type the OR operator || (also called pipe)

Would be great if this section had a short mention of how to type the || on the eyboard.

6 Likes

The operator for logical OR is actually two characters, not one. Look for the pipe character, | on your keyboard. On a standard American keyboard it’s usually on the backslash \ key. Shift that and you get |.

31 Likes

Mine is Danish, but I found it. Thanks

2 Likes

For reference, what key did you find it on?

3 Likes

Yes, it’s the key left of the backspace. It has the following symbols on it ´ `. pressing alt gr annd that will give a pipe |

3 Likes

I use a Spanish keyboard and on that the pipe character | is on the same key for 1 and !. You get | by holding down Alt Gr

i.e.

| = Alt Gr + 1

5 Likes

Hi there! On a French MacBook Pro keyboard the pipe character is shift + alt + L.

12 Likes

On mac with a Danish keyboard it is option + i twice.

2 Likes

Finnish keyboard it is located on left next to the letter Z. Alt gr + that key will result to |.

4 Likes

If you still cant find | you can get it by using your number pad on your keyboard and alt. (make sure you have Number Lock on). So to get the symbol | you hold down alt then while holding it down put in 124 (on your number pad) and let go of alt . This should get the symbol you need. Do this twice to get what you need.

5 Likes

Thanks alt codes are so much easier

1 Like

Thank you! My old laptop had this key to the left of Z, but i bought a desktop and my new keyboard doesn’t have anything between Shift and Z. It’s a brazilian keyboard.

2 Likes

On Turkish “altgr + <” that is just near z

3 Likes

on normal keyboard its right above the enter
Note : type it two time using shift

1 Like

On my UK keyboard the symbols are switched so ‘¦’ button produces the unbroken pipe ‘|’ and vice versa. Can someone please explain the reasoning behind this or was my keyboard just made by a simpleton?

1 Like

I’ve seen them mixed up before but I’m not sure why. From what I understand pipe is normally a shifted backslash on a UK keyboard. I’ve seen the symbol for this as both the expected combination of \ and | and the one you mentioned of \ and ¦. Then again even for “UK” keyboards backtick and backslash seem to swap around often enough along with several other keys so I’ve assumed the actual convention for designers is to be consistently inconsistent.

Perhaps with a web search you’ll find a method in the madness but it would surprise me :joy:.

Hopefully the muscle memory will kick in after a while so you don’t have to look for the symbol, I think that’s better than trying to catch incoming scan codes (maybe there’s a simple change but I’ve never looked for it). Depending on your keyboard the keycaps might be removable and there might be replacements (less common for non-mechanical boards and size, shape, font etc. are hard to match but they do exist) though it hardly seems worth the bother.

Thanks! You saved me!.. I alraedy tried the double" i" and double “L”.

1 Like

thanks ! helped a lot !

Would you recommend using the standard U.S international P.C keyboard configuration for code?

Thanks in advance.

That’s not something I can recommend. The one that is in common use in your locale would be the one to use, I would think. From what I understand, JavaScript can work with any encoding since it internally converts it to unicode.

2 Likes