[Question]
  [
# Objective
Given an ASCII character, toggle its "shift-ness" on the standard US keyboard (ANSI-INCITS 154-1988 (R1999)), then output it.
# Mapping
```
) ↔️ 0
! ↔️ 1
@ ↔️ 2
# ↔️ 3
$ ↔️ 4
% ↔️ 5
^ ↔️ 6
& ↔️ 7
* ↔️ 8
( ↔️ 9
" ↔️ '
+ ↔️ =
, ↔️ <
- ↔️ _
. ↔️ >
/ ↔️ ?
: ↔️ ;
(Capital Latin letters) ↔️ (Small Latin letters)
[ ↔️ {
\ ↔️ |
] ↔️ }
` ↔️ ~
(ASCII whitespaces and control characters are left intact)
```
# Rule
* Non-ASCII characters fall into *don't care* situation.
# Examples
Given a character `0`, output `)`.  
Given a character `C`, output `c`.  
Given a character  (space), output .  
Given a character `\t` (horizontal tab), output `\t`.  
Given a character `\a` (bell), output `\a`.
  
[Answer]
# x86-16, Genuine IBM PC, ~~32~~ ~~31~~ 29 bytes
```
00000000: b4f0 8ec0 bfe5 e8b3 3ab1 74a0 8200 f2ae  ........:.t.....
00000010: 3acb 7f02 f7db 268a 41ff cd29 c3         :.....&.A..).
```
Build with `xxd -r`.
**Unassembled listing:**
```
B4 F0       MOV  AH, 0F0H               ; BIOS segment address (F000H)
8E C0       MOV  ES, AX                 ; set ES to BIOS segment for SCASB
BF E8E5     MOV  DI, E8E5H              ; set to LABEL K10 
B3 3A       MOV  BL, 58                 ; size of table 
B1 74       MOV  CL, 58*2               ; size of both tables 
A0 0082     MOV  AL, BYTE PTR DS:[82H]  ; get input char from command line 
F2/ AE      REPNZ SCASB                 ; search BIOS table for char 
3A CB       CMP  CL, BL                 ; found in the lowercase table? 
7F 02       JG   UPPER                  ; if so, convert with uppercase table by adding
F7 DB       NEG  BX                     ; otherwise subtract the offset 
        UPPER: 
26:8A 41 FF MOV  AL, ES:[BX+DI-1]       ; get char from table
CD 29       INT  29H                    ; DOS fast write to console 
C3          RET                         ; return to DOS
```
**Input/Output:**
[![enter image description here](https://i.stack.imgur.com/VGUoi.png)](https://i.stack.imgur.com/VGUoi.png)
**How does it work?**
Well, the PC BIOS already contains all of the code and tables necessary for this since it actually handles the conversion of scan codes received from the keyboard to ASCII chars (in real/DOS mode at least). There's no way (that I know of) to actually hook this on just *any* "PC-compatible" BIOS, however if you know the location of the table in ROM (on the IBM PC it starts at `F000:E8E5`), you can use that.
On Page A-25 of Appendix A the [IBM PC Technical Reference](https://ibm.retropc.se/manuals/IBM_5150_Technical_Reference_6025005_AUG81.pdf) (listing of the entire source code of the PC BIOS) is the disassembly of this table:
[![enter image description here](https://i.stack.imgur.com/yenCh.png)](https://i.stack.imgur.com/yenCh.png)
Unfortunately, this address will be different on any given PC-clone BIOS and of course, there's no guarantee that it would even be implemented in the same way by anyone else. Thus, this submission is guaranteed to run only on a *Genuine IBM PC*. Go Big Blue!
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~110 ... 97~~ 96 bytes
```
c=>(s=")0@2^6&7*8(9\"'+=-_:;`~")[s.indexOf(c)^1]||(B=Buffer)([([n]=B(c),n%127>32)<<4+n/64^n])+''
```
[Try it online!](https://tio.run/##XY5BT8JAFITv/IqXJtr3XKm0EEDbJabcPMiBY2m1KV2swbdmFw0E9OgP8Cf6R@rCkctkkm8yM6/lZ2kr07xvuqyXdatkW8kJWulR7z4qhpejqzHeLjxfyO7TXfz87VFmg4aX9XamsKIizA8HTGX6oVRtCDPMOJepI9d8EUajST@iJBkIvhkOCs5J@H6rtEEGCb0YGBIIo7EzQhDsOwCVA/ONaXgVKKPfpi@lmbpjyBQfqWar13Ww1it8mM8eA3uKNmrnFkGAD38/v04FnNHjV3IVX@0/ "JavaScript (Node.js) – Try It Online")
### How?
We use a lookup table for these pairs:
```
) ↔️ 0
@ ↔️ 2
^ ↔️ 6
& ↔️ 7
* ↔️ 8
( ↔️ 9
" ↔️ '
+ ↔️ =
- ↔️ _
: ↔️ ;
` ↔️ ~
```
For all other characters, we use the following code:
```
(B = Buffer)([   // generate a buffer from a singleton array:
  (              //
    [n] = B(c),  //   n = ASCII code of the input character
    n % 127 > 32 //   1 if 32 < n < 127, or 0 otherwise
  )              //
  << 4 + n / 64  //   left-shifted by 4 if n < 64, or by 5 otherwise
  ^ n            //   XOR'ed with n
]) + ''          // end of Buffer(); coerce it to a string
```
which supports these 3 cases:
* If \$32<n<64\$, we XOR the ASCII code with \$16\$, which is what we need for:
```
! ↔️ 1
# ↔️ 3
$ ↔️ 4
% ↔️ 5
, ↔️ <
. ↔️ >
/ ↔️ ?
```
* If \$64\le n<127\$, we XOR the ASCII code with \$32\$, which toggles the case of letters and also works for these pairs:
```
[ ↔️ {
\ ↔️ |
] ↔️ }
```
* If \$n\le32\$ or \$n=127\$, the character is left unchanged (ASCII code XOR'ed with \$0\$).
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 34 bytes
```
T`-~A-]d';-?/.+,:"(*&^%$#@!)}-_`Ro
```
[Try it online!](https://tio.run/##Xc89TgJRFAXg/qzi8v8GGMB/BRUIFQmV2CkwL8MzTDLOkDcvsUAobW1cjOtxAy5hHItjYfflnuTcHGtclOg8vw/8w9hfrBsDf9jttNr9smrWl7VqZVTy9v4quEvz3JOvt4/vz3fpoUQeYUQeo0KeoEqeokaeYUmeo05eoEleQpFXKJMNtMgbtMlr@OQKHfIWXXKIPjmAmuht5HQsM13sldg4Z2z2N0jNn3X8P8QD4x0eyVcsyD0C8gA1nk@mU3nZRM5kWx2aTHSyljBNnE1jCTfa6vC3VrQ1xYsnJ1HiipP3Aw "Retina 0.8.2 – Try It Online") Link includes test cases.
Explanation: The `T` command is Retina's transliteration operation. Among its special characters are:
* ```: Delimit the parts of the command
* `-`: Introduce a range (this suppresses the following special characters so `d-o` just means `defghijklmno`)
* `_`: Delete the matching character
* `d`: `0-9`
* `R`: Reverse the next range
* `o`: Take the source string as the range
The trick is therefore to create as many ranges as possible to reduce the length, plus avoiding having the `-` and `_` characters where they would be interpreted as a special character and avoiding the ``` at all by including it inside a range. Additionally arranging for the range to transliterate to its reversal allows that to be expressed very cheaply.
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + core utilities, ~~58~~ \$\cdots\$ ~~51~~ 49 bytes
Added ~~47~~ 50 bytes to fix a bug kindly pointed out by [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe).  
Saved 8 bytes thanks to [Value Ink](https://codegolf.stackexchange.com/users/52194/value-ink)!!!  
Saved 2 bytes thanks to [Mitchell Spector](https://codegolf.stackexchange.com/users/59825/mitchell-spector)!!! 
```
a='"A-]`=<_>?)!@#$%^&*(;'
b=\'a-~+-:
tr $a$b $b$a
```
[Try it online!](https://tio.run/##PYvLDoIwFET3/YoRq4AG4lZLQf/jKhaB8EiKAVby@PWKMbqZTM6ZSVRXmN5xB6OkbV28610GcRi5q/Oab27bnSNslkiylTfvvRPrW3DFE/CEKzOxvGlRotQYDr5/nEA2SIICUAwKQRFIYFC@/1rcABpBS5kF0oZVkjvZo2jAS4zoXVH/QfUFz7bUfQ5r08EL8UvS1ueyjHgtWNrozLwB "Bash – Try It Online")
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 86 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
This solution [has been out-golfed](https://codegolf.stackexchange.com/a/199947/43319) but is preserved due to being interesting for its sourcing of the data.
Anonymous prefix lambda. Requires 0-based indexing (`⎕IO←0`).
```
{⍵∊a←↑'[!-~]{2}'⎕S'&'↓⍉↑'\w\w...'⎕R(5⍴'')↓11 71↑30↓⎕FMT⌂notes.keyboards:a⌷⍨~@1⊃⍸⍵=a⋄⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qG@qp/@jtgkG/6sf9W591NGVCOQ8apuoHq2oWxdbbVSrDlQRrK6m/qht8qPeTpBMTHlMuZ6eHkgiSMP0Ue8WdXVNoKyhoYK5IVDe2ACktG@qm2/Io56mvPyS1GK97NTKpPzEopRiq8RHPdsf9a6oczB81NX8qHcH0FLbxEfdLUC69n8ayO7ePrDMGqDBh9YbAw0EOSDIGUiGeHgG/09TUDdQ5wKSzmBSAUxygkl2dQA "APL (Dyalog Extended) – Try It Online")
This works by extracting the character pairs from [a built-in note about keyboards](https://dfns.dyalog.com/n_keyboards.htm).
`{`…`}` "dfn"; argument character is `⍵`:
 `⌂notes.keyboards` the built-in string
 `⎕FMT` ForMaT as a character matrix
 `30↓` drop the first 30 lines
 `11 71↑` take the first 11 lines' first 71 columns
 `↓` split into list of strings
 `'\w\w...'⎕R(`…`)` PCRE **R**eplace word-character,word-character,any-symbol,any-symbol with:
  `''` the empty string
  `5⍴` reshaped to length 5, padding with spaces; i.e. 5 spaces
 `↑` mix list of strings into character matrix
 `⍉` transpose
 `↓` split matrix into list of strings
 `'[!-~]{2}'⎕R'&'` PCRE **S**earch and return any pair of printable ASCII characters
 `↑` mix list of character pairs into two-column matrix
 `a←` store in `a` (for ***a***ll)
 `⍵∊`…`:` if the argument character is a member of that matrix:
  `⍵=` Boolean matrix mask where they are equal
  `⍸` get indices where true
  `⊃` pick the first (row,column) pair
  `~@1` negate the number at position 1 (the column; i.e. 1→0 and 0→1)
  `a⌷⍨` use that to index into the matrix of **a**ll pairs
 `⋄` else:
  `⍵` the argument character
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~38~~ 37 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“Æz⁶ɦG!€u<ʂCP]ƭƝ’œ?ØṖḟØB¤ḊØD;ṙ21,ƊyŒs
```
A monadic Link accepting a list of characters which yields a list of characters.
**[Try it online!](https://tio.run/##AYQAe/9qZWxsef//4oCcw4Z64oG2yaZHIeKCrHU8yoJDUF3Grcad4oCZxZM/w5jhuZbhuJ/DmELCpOG4isOYRDvhuZkyMSzGinnFknP///8HQmVsbAlUYWIgU3BhY2UpIUAjJCVeJiooIissLS4vOltcXWAwMTIzNDU2Nzg5Jz08Xz4/O3t8fX4 "Jelly – Try It Online")**
### How?
Forms a mapping for non alphabetic characters, applies the translate atom, `y`,
and then swaps case.
```
“Æz⁶ɦG!€u<ʂCP]ƭƝ’œ?ØṖḟØB¤ḊØD;ṙ21,ƊyŒs - Link: list of characters, S
“Æz⁶ɦG!€u<ʂCP]ƭƝ’                     - base 250 number              =53994992086540427749431907521542401
                        ¤             - nilad followed by link(s) as a nilad:
                   ØṖ                 -   printable characters       = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
                      ØB              -   base-62 characters         =0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
                     ḟ                -   filter discard             = !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
                 œ?                   - lexicographical permutation  = '=<_>?;{|}~)!@#$%^&*("+,-./:[\]`
                         Ḋ            - dequeue                      ='=<_>?;{|}~)!@#$%^&*("+,-./:[\]`
                          ØD          - digit characters             =0123456789
                            ;         - concatenate                  =0123456789'=<_>?;{|}~)!@#$%^&*("+,-./:[\]`
                                 Ɗ    - last three links as a monad:
                              21      -   twenty-one
                             ṙ        -   rotate left                =)!@#$%^&*("+,-./:[\]`0123456789'=<_>?;{|}~
                                ,     -   pair                       =)!@#$%^&*("+,-./:[\]`0123456789'=<_>?;{|}~ and 0123456789'=<_>?;{|}~)!@#$%^&*("+,-./:[\]`
                                  y   - translate (S)
                                   Œs - swap case
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~99~~ 95 bytes
Same strategy as @Arnauld's answer.
*-4 bytes thanks to @mypetlion*
```
lambda c,s=")0!1@2#3$4%5^6&7*8(9\"'+=,<-_.>/?:;[{\\|]}`~":[c.swapcase(),s[s.find(c)^1]][c in s]
```
[Try it online!](https://tio.run/##Fc1JDoIwGEDhvaf4xalVRAEHRFHv0RathUoTLaQlMcbh6oi7t/nyqmddlDpsJCRAmxu/XzIOwrWJg@dd/xj0wv5isExXw/U4QhvqjCaJu5uevP3sEG/Ji9I3@5y/TkyEZx@8EtzmCLuWWE8qnSGBU58xIkBpsKyRpQH1b8P1NUd@EOG4A6J9i8IghTtQGaVrJFuImx8 "Python 3 – Try It Online")
## Explanation
* `s=")0!1@2#3$4%5^6&7*8(9\"'+=,<-_.>/?:;[{\\|]}`~"` contains all pairs of special toggles.
* `s[s.index(c)^1]` gets the index of the other character from the same pair
* If the character is a Latin or control character (`c in s` is `False`), `c.swapcase()` is returned. `c.swapcase()` toggles the case of a Latin character, but doesn't affect control character.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~53~~ ~~36~~ 35 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.šžQžiмDœ•1ĀêŽƵÆ{çIΣeÿí‚Ð"pkālrÙ•è‡
```
-1 byte implicitly thanks to *@Grimmy* due to his comment.
[Try it online](https://tio.run/##AUcAuP9vc2FiaWX//y7FocW@UcW@adC8U0TigKIxxIDDqsW9xrXDhnvDp0nOo2XDv8Ot4oCaw5AicGvEgWxyw5nigKIuSeKAof//Xg) or [verify all printable ASCII characters](https://tio.run/##AVYAqf9vc2FiaWX/xb5Rdnk/IiDihpIgIj95/y7FocW@UcW@adC8U0TigKIxxIDDqsW9xrXDhnvDp0nOo2XDv8Ot4oCaw5AicGvEgWxyw5nigKIuSeKAof8s/w). NOTE: The TIO versions use the `S•...•.I` (builtin for the n'th permutation of a list) instead of `œ•...•è` (push all permutations of the string (extremely slow bottleneck for a string this large), and index into it).
**Explanation:**
```
.š        # Switch-case of the (implicit) input-character (if it's a letter)
  žQ      # Push all printable ASCII characters:
          #   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
    žiм   # Remove all letters [A-Za-z]:
          #   !"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~
  D       # Duplicate it
   œ      # Push a list of all permutations of this string
    •1ĀêŽƵÆ{çIΣeÿí‚Ð"pkālrÙ•
         "# Push compressed integer 540470878544692028277787799913384202055137480696656
     è    # Index it into the string-list of permutations:
          #   1'3457"908=<_>?)!@#$%^&*(;:,+./2{|}6-~[\]`
  ‡       # Transliterate the characters at the same indices
          # (after which the result is output implicitly)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `•1ĀêŽƵÆ{çIΣeÿí‚Ð"pkālrÙ•` is `540470878544692028277787799913384202055137480696656`.
This number(+1) is generated by [the Jelly builtin `Œ¿`](https://tio.run/##y0rNyan8///opEP7////r2Cobmxiaq5kaWBhaxNvZ6@p6KCsohqnpqVhbaWjradvVF1Ta6ZbFx0Tm/BfQVEJKKemrqGppa2jq6dvYGgE1GtmbmFpZW1ja2fvAFQVF58A1FEHAA), which gets the 1-based index of the permutation.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, ~~92~~ 91 bytes
*-1 byte thanks to @ValueInk*
```
s/[]a-z{}|\\[]/$&^$"/gei;y/0-9)!@#$%^&*(`~\-=_+';":,.\/<>?/)!@#$%^&*(0-9~`_+\-=":';<>?,.\//
```
[Try it online!](https://tio.run/##K0gtyjH9/79YPzo2UbequrYmJiY6Vl9FLU5FST89NdO6Ut9A11JT0UFZRTVOTUsjoS5G1zZeW91ayUpHL0bfxs5eHyEJVFmXEK8NVKFkpW4NlAMp0f//PzEpOSIyytDI2MTUzNzC0gChIzo2pqa2@l9@QUlmfl7xf11fUz0DQ4P/ugUA "Perl 5 – Try It Online")
[Answer]
# Pure [Bash](https://www.gnu.org/software/bash/), ~~170~~ 165 bytes
```
a=`echo {A..Z}`')!@#$%^&*("+,-./:[\]`'
b=`echo {a..z}`0123456789"'=<_>?;{|}~"
c=$a$b
d=$b$a
for((;n<164;n++)){ [ "$1" = "${c:n:1}" ]&&echo ${d:n:1}&&exit;}
echo "$1"
```
[Try it online!](https://tio.run/##NYzdDsEwAEbv@xRVtR@jlBnWFXsNM9puZG62BBei6tVrlrj6ck5OPiXvlbWSi3NRNVCnhOyNcP3ero8HR2fooWA0JpM4O@TCBeqfSUJeRkzpbB4uouVqjVyenDZbpt/mg0DBscQKlBwrLMGluXkeqxMahawOAt/XMIMIUwR5O7qI65gaBHPH6b6xLjvT4vP6YAZ09tdba9Mv "Bash – Try It Online")
I decided to implement a solution inspired by @Noodle9's very nice answer, but using pure bash without any utilities (like tr).
Note that you need to run this in an empty directory; this can be fixed at the cost of 2 bytes by using quotes for `"{d:n:1}"`. (This issue only arises with a non-empty current directory when the input is `8`, so the output is supposed to be `*`.)
On the other hand, you can gain 2 bytes if you don't require output for the input `\n`: just eliminate the quotes in the final `echo`.
[Answer]
# [Julia](http://julialang.org/), 87 bytes
```
x->Char[0:32;b"1'3457\"908=<_>?)!@#$%^&*(;:,+./2";97:125;b"6-~";65:93;96;127][Int(x)+1]
```
[Try it online!](https://tio.run/##HY7LboJAAEX39yuu44PB94CAMII2XfUXimhpKimNoQamqenDX6fWszirk5v79nEsc3Vui7g9T5L717xO55Hr6GehLHfhBVsRzpfxap@s7c6m2@vvBkOpo/FoOnOEDoNIOd619ScXoX0vCl0d@lo5QZY@VEae7ZHKWnNoTMOYdf4phIDNOTpU2NBBly56XKBPDzv6GDDAkEtIhhC0MGKMMVeYcI8pE8y4RkSNlN/Y8gcZf/HEC3Le4YuP//Mo3msalhXToqwbM5XN6VgaeXth25oWrau21c3KysArp7qszLGShnHCQhrbxqF6QfsH "Julia 1.0 – Try It Online")
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 60 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous tacit prefix function.
```
-(,⊃⍨⍳-¯1*⍳)⍨('"''+=,<-_.>/?:;[{\|]}`~',∊')!@#$%^&*(',¨⎕D),-
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X1dD51FX86PeFY96N@seWm@oBaQ1gVwNdSV1dW1bHRvdeD07fXsr6@jqmJrY2oQ6dZ1HHV3qmooOyiqqcWpaGuo6h1Y86pvqoqmj@z/tUduER719YAPXPOrdcmi98aO2iUDZ4CBnIBni4Rn8P01B3UCdC0g6g0kFMMkJJtnVAQ "APL (Dyalog Extended) – Try It Online")
`-` swap case
`(`…`),` prepend the following:
 `⎕D` the digits
 `')!@#$%^&*(',¨` prepend each of these characters to the corresponding digit
 `∊` **ϵ**nlist (flatten)
 `'"''+=,<-_.>/?:;[{\|]}`~',` prepend these characters (`''` is an escaped single quote)
`-(`…`)⍨` apply the following function with that as *left* argument and the case-swapped original argument as *right* argument:
 `⍳` **ɩ**ndex of the case-swapped argument in the substitution string
 `¯1*` negative one raised to that power
 `⍳-` subtract that from the **ɩ**ndex of the case-swapped argument in the substitution string
 `,⊃⍨` use that to pick an element from the case-swapped argument appended to the substitution string
[Answer]
# Pure [Bash](https://www.gnu.org/software/bash/), 217 bytes
```
P=printf\ 
a=`$P%x "'$1"`
case $a in 3[ab])x=1;;2[27])x=5;;2[68]|3[79])x=17;;2a|38)x=18;;2b|3d)x=22;;29|30)x=25;;36|5e)x=104;;2d|32|40|5f)x=114;;20|7f)x=0;;60|7e)x=30;;[23]?)x=16;;[4-7]?)x=32
esac
$P\\`$P%o $[0x$a^x]`
```
[Try it online!](https://tio.run/##Hc7PCoMwDAbwu09RRsfYYVAbtUqRsTfwXjus/5gXN@YOHvLuXeLtly9fIH3YXjE29ee7rL@5FUmoO9mcd3G6yPTUJUPYJiGDWFYBLvT@uteptdppw8yZRekRnKmOnaEkIJTsktwjjGStyRWCYtMVFJhP3FEZLUYEjZnCfOYo5Uih4UFZWxC5CmSnwd@5U5CzmzkG0Mm0hSGRTdvy728hndpleO6@izE@/g "Bash – Try It Online")
Just bash -- no Unix utilities.
Input character is passed as an argument, and the output is on stdout.
**\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_**
**Test runs:**
```
$ cat shifttoggle
P=printf\ 
a=`$P%x "'$1"`
case $a in 3[ab])x=1;;2[27])x=5;;2[68]|3[79])x=17;;2a|38)x=18;;2b|3d)x=22;;29|30)x=25;;36|5e)x=104;;2d|32|40|5f)x=114;;20|7f)x=0;;60|7e)x=30;;[23]?)x=16;;[4-7]?)x=32
esac
$P\\`$P%o $[0x$a^x]`
$cat shifttoggleTest
#!/bin/bash
count=1
for s in ')!@#$%^&*("+,-./:' "0123456789'=<_>?;" ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz '[\]`' '{|}~' $' \a\n\r\t\x7F\x80\x88\x8F'
  do
    echo "TEST #$count"
    for ((n=0;n<${#s};n++))
      do
        c="${s:$n:1}"
        d=`./shifttoggle "$c"`
    # Backticks remove any trailing newline, so restore that here for the case where c is \n (you can check that shifttoggle really prints \n in that case).
    if test -z "$d"
          then
            d=$'\n'
        fi
    if test "$count" -eq 7
          then
            printf "  ASCII %d => ASCII %d\n" "'$c" "'$d"
      else
            echo "  $c => $d"
        fi
      done
      (( count++ ))
      echo ''
  done
$ ./shifttoggleTest 
TEST #1
  ) => 0
  ! => 1
  @ => 2
  # => 3
  $ => 4
  % => 5
  ^ => 6
  & => 7
  * => 8
  ( => 9
  " => '
  + => =
  , => <
  - => _
  . => >
  / => ?
  : => ;
TEST #2
  0 => )
  1 => !
  2 => @
  3 => #
  4 => $
  5 => %
  6 => ^
  7 => &
  8 => *
  9 => (
  ' => "
  = => +
  < => ,
  _ => -
  > => .
  ? => /
  ; => :
TEST #3
  A => a
  B => b
  C => c
  D => d
  E => e
  F => f
  G => g
  H => h
  I => i
  J => j
  K => k
  L => l
  M => m
  N => n
  O => o
  P => p
  Q => q
  R => r
  S => s
  T => t
  U => u
  V => v
  W => w
  X => x
  Y => y
  Z => z
TEST #4
  a => A
  b => B
  c => C
  d => D
  e => E
  f => F
  g => G
  h => H
  i => I
  j => J
  k => K
  l => L
  m => M
  n => N
  o => O
  p => P
  q => Q
  r => R
  s => S
  t => T
  u => U
  v => V
  w => W
  x => X
  y => Y
  z => Z
TEST #5
  [ => {
  \ => |
  ] => }
  ` => ~
TEST #6
  { => [
  | => \
  } => ]
  ~ => `
TEST #7
  ASCII 32 => ASCII 32
  ASCII 7 => ASCII 7
  ASCII 10 => ASCII 10
  ASCII 13 => ASCII 13
  ASCII 9 => ASCII 9
  ASCII 127 => ASCII 127
  ASCII 128 => ASCII 128
  ASCII 136 => ASCII 136
  ASCII 143 => ASCII 143
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 100 bytes
```
char*strchrnul(),*s=")0@2^6&7*8(9\"'+=-_:;`~\0";f(c){c=s[strchrnul(s,c)-s^1]?:(c%127>32)<<4+c/64^c;}
```
Similar to the Javascript strategy. I'd like to get rid of the extra parentheses but this is pretty good.
[Try it online!](https://tio.run/##lY/NDoIwEITvPEXTRG35iYAEkIL6HiJKVhESLaYFLwRfHQvReHZOk9l8u7NgXQGGAcpc6LIRUAre3gg1dZlgau/czJ8HekjWKV4YiXWM2OmV2pgVBGgHidz/GGkCtWTmHLYRgZnjBpuVS@PYM2Dpexmwfqh4g@55xcmzrs5U6zSkNIbAtMkXtSCAEmQzBChGjhsqYxh0Go56tM3YVB3/ECqQBKcc039XjB98IXFpWsEVo/XDGw "C (gcc) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-p`, 66 bytes
Builds the "lowercase" and "uppercase" strings so that everything lines up, and connects them together to be passed into the `tr` function so it can do the proper conversions.
```
l="\\-a-z0-9=[-];',./`"
u='_A-Z)!@#$%^&*(+{|}:"<>?~'
$_.tr!u+l,l+u
```
[Try it online!](https://tio.run/##KypNqvz/P8dWKSZGN1G3ykDX0jZaN9ZaXUdPP0GJq9RWPd5RN0pT0UFZRTVOTUtDu7qm1krJxs6@Tp1LJV6vpEixVDtHJ0e79P//BEMjYxNTM3MLSwNdW67C8tSiksrSzPyC6NgYrsTilLT0jKzsHGt1rqqK5LKkvFygBVxcdXCDNeO1uQLDXYNCIkM9/QOqa2u4HINd3Nw9vLx9rJS4oiKcw5z8fIH2cnF5pObk5OsolOcX5aQo/ssvKMnMzyv@r1sAAA "Ruby – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 189 bytes
```
param($x)if(($s=")0@2^6&7*8(9""'+=-_:;``~").contains($x)){$s[$s.indexof($x)-bxor1]}else{
$n=[byte][char]$x;if($n-in32..64){[char]($n-bxor16)}elseif($n-in65..127){[char]($n-bxor32)}else{$x}}
```
[Try it online!](https://tio.run/##XY3RCoIwAEXf@4wxaiscqTUrEfqJnsRy2sSBbbIJLcR@faXSS6/nnsNt1ZNrU/Omca5lmj0QtFhUCEGTALw9B1e6jNYHdARgtUm82ynO8zfApFSyY0KaUcc9NCk0RMg7t6oakVdYpf1s4I3h/QLKJC1eHc/SsmY6gzb@PkDpCRkGhNAd7udhZFNI8VT@LLonxA@ify0MZq2Hdhicc5cP "PowerShell – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 111 bytes
```
$k=')!@#$%^&*("+,-./:[\]`'+'A'..'Z'+"0123456789'=<_>?;{|}~"+'a'..'z'
"$k$k$args"[($p=$k|% i*f @args)+72*!!++$p]
```
[Try it online!](https://tio.run/##RZDbUsIwEIbv8xRLCGxLCiIe8FSswwPIDHeWCjWmUkFa0zI6Qn31mrSMbGaSf3f//TJJmnxJlS3lel2yCFzYlWzlot3wmqz13O5YlDvd3smNPwsWyPEBez18Qk77p4Oz84vL4dU1unfz0f3tbl/8Uo6hMfwgoWylV6jeMupbLHXZat@CuBOBZ2o2Hw46jQbnLA3KghDPIsSxsI8O2mgbaWvZr@UYHUBRazAaKk0XOXXMZhJfLEMVDJ3DaQM0Ic4hzkAkSkmRA85ChChRMPl/cAVRBqJoTdyYZKMTYsMeWrAjoIMZqANMfqeaJF/1L7F53VEy265zXWjrz6t8Vd2fTMfbLE8@Hl/e9Ujg1SAT060QMssM4zDcFfLzCD8al3F0uKw2Vp2CFOUf "PowerShell – Try It Online")
`i*f` is shortcut for `indexOf`.
Explain:
* The shift series contains 72 chars `)!@#..A B C.. Y Z`.
* The shift-ness series contains 72 chars also
* `$k` contains concatenated shift and shift-ness series
* if `$args` does not found in `$k`, then `indexOf` returns `-1` and script returns the last char from string `$k+$k+$args`. It is `$args`.
* if `$args` found in `$k`, then the script return shifted char.
]