One line Keyboard

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












The Challenge



The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.



This is code golf, so shortest solution in bytes wins!





IO

Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may assume for this challenge that an empty String requires no typing and thus can be typed using a single line.



You may take the input as a String, list of characters, or equivalent form for your language.



Output should be a truthy value for any String that can be typed using a single line, or falsey for one that cannot.





Keyboard layout

To clarify any ambiguity over what the standard keyboard layout is below is a list of keys available on each line, including alternate upper keys (accessed using shift).




  • Line 1

    • Standard: `1234567890-=



  • Line 2

    • Standard: qwertyuiop



  • Line 3

    • Standard: asdfghjkl;'#

    • Uppercase: ASDFGHJKL

    • Special: Caps Lock



  • Line 4

    • Standard: zxcvbnm,./

    • Alternate: |<>?

    • Uppercase: ZXCVBNM

    • Special: Shift



  • Line 5

    • Special: Space Bar


Alternate upper keys can only be pressed if Shift is also on the same line, and uppercase keys can only be accessed through Caps Lock or Shift. You really can only use one keyboard line!





Test cases

 -> true (empty string)
45-2=43 -> true (line 1)
qwerty -> true (line 2)
tryitout -> true (line 2)
Qwerty -> false (no shift or caps on line 2)
#sad -> true (line 3)
AsDf -> true (caps lock used)
@sDF -> false (no shift for alternate upper)
zxcvbn? -> true (line 4)
zxc vbn -> false (spacebar on separate line)
123abc -> false (multiple lines)
-> true (just space bar)
!!! -> false (exclamation marks cannot be printed by a single line)









share|improve this question























  • So this is strictly U.S. keyboard layouts? (I've got a UK layout).
    – ouflak
    48 mins ago











  • @ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
    – Luke Stevens
    46 mins ago










  • @Arnauld Yes I did, thanks for noticing!
    – Luke Stevens
    46 mins ago










  • Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
    – ouflak
    45 mins ago











  • Are we allowed to take the input as a list of characters, or does it have to be a string?
    – Kevin Cruijssen
    41 mins ago















up vote
3
down vote

favorite












The Challenge



The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.



This is code golf, so shortest solution in bytes wins!





IO

Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may assume for this challenge that an empty String requires no typing and thus can be typed using a single line.



You may take the input as a String, list of characters, or equivalent form for your language.



Output should be a truthy value for any String that can be typed using a single line, or falsey for one that cannot.





Keyboard layout

To clarify any ambiguity over what the standard keyboard layout is below is a list of keys available on each line, including alternate upper keys (accessed using shift).




  • Line 1

    • Standard: `1234567890-=



  • Line 2

    • Standard: qwertyuiop



  • Line 3

    • Standard: asdfghjkl;'#

    • Uppercase: ASDFGHJKL

    • Special: Caps Lock



  • Line 4

    • Standard: zxcvbnm,./

    • Alternate: |<>?

    • Uppercase: ZXCVBNM

    • Special: Shift



  • Line 5

    • Special: Space Bar


Alternate upper keys can only be pressed if Shift is also on the same line, and uppercase keys can only be accessed through Caps Lock or Shift. You really can only use one keyboard line!





Test cases

 -> true (empty string)
45-2=43 -> true (line 1)
qwerty -> true (line 2)
tryitout -> true (line 2)
Qwerty -> false (no shift or caps on line 2)
#sad -> true (line 3)
AsDf -> true (caps lock used)
@sDF -> false (no shift for alternate upper)
zxcvbn? -> true (line 4)
zxc vbn -> false (spacebar on separate line)
123abc -> false (multiple lines)
-> true (just space bar)
!!! -> false (exclamation marks cannot be printed by a single line)









share|improve this question























  • So this is strictly U.S. keyboard layouts? (I've got a UK layout).
    – ouflak
    48 mins ago











  • @ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
    – Luke Stevens
    46 mins ago










  • @Arnauld Yes I did, thanks for noticing!
    – Luke Stevens
    46 mins ago










  • Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
    – ouflak
    45 mins ago











  • Are we allowed to take the input as a list of characters, or does it have to be a string?
    – Kevin Cruijssen
    41 mins ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











The Challenge



The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.



This is code golf, so shortest solution in bytes wins!





IO

Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may assume for this challenge that an empty String requires no typing and thus can be typed using a single line.



You may take the input as a String, list of characters, or equivalent form for your language.



Output should be a truthy value for any String that can be typed using a single line, or falsey for one that cannot.





Keyboard layout

To clarify any ambiguity over what the standard keyboard layout is below is a list of keys available on each line, including alternate upper keys (accessed using shift).




  • Line 1

    • Standard: `1234567890-=



  • Line 2

    • Standard: qwertyuiop



  • Line 3

    • Standard: asdfghjkl;'#

    • Uppercase: ASDFGHJKL

    • Special: Caps Lock



  • Line 4

    • Standard: zxcvbnm,./

    • Alternate: |<>?

    • Uppercase: ZXCVBNM

    • Special: Shift



  • Line 5

    • Special: Space Bar


Alternate upper keys can only be pressed if Shift is also on the same line, and uppercase keys can only be accessed through Caps Lock or Shift. You really can only use one keyboard line!





Test cases

 -> true (empty string)
45-2=43 -> true (line 1)
qwerty -> true (line 2)
tryitout -> true (line 2)
Qwerty -> false (no shift or caps on line 2)
#sad -> true (line 3)
AsDf -> true (caps lock used)
@sDF -> false (no shift for alternate upper)
zxcvbn? -> true (line 4)
zxc vbn -> false (spacebar on separate line)
123abc -> false (multiple lines)
-> true (just space bar)
!!! -> false (exclamation marks cannot be printed by a single line)









share|improve this question















The Challenge



The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.



This is code golf, so shortest solution in bytes wins!





IO

Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may assume for this challenge that an empty String requires no typing and thus can be typed using a single line.



You may take the input as a String, list of characters, or equivalent form for your language.



Output should be a truthy value for any String that can be typed using a single line, or falsey for one that cannot.





Keyboard layout

To clarify any ambiguity over what the standard keyboard layout is below is a list of keys available on each line, including alternate upper keys (accessed using shift).




  • Line 1

    • Standard: `1234567890-=



  • Line 2

    • Standard: qwertyuiop



  • Line 3

    • Standard: asdfghjkl;'#

    • Uppercase: ASDFGHJKL

    • Special: Caps Lock



  • Line 4

    • Standard: zxcvbnm,./

    • Alternate: |<>?

    • Uppercase: ZXCVBNM

    • Special: Shift



  • Line 5

    • Special: Space Bar


Alternate upper keys can only be pressed if Shift is also on the same line, and uppercase keys can only be accessed through Caps Lock or Shift. You really can only use one keyboard line!





Test cases

 -> true (empty string)
45-2=43 -> true (line 1)
qwerty -> true (line 2)
tryitout -> true (line 2)
Qwerty -> false (no shift or caps on line 2)
#sad -> true (line 3)
AsDf -> true (caps lock used)
@sDF -> false (no shift for alternate upper)
zxcvbn? -> true (line 4)
zxc vbn -> false (spacebar on separate line)
123abc -> false (multiple lines)
-> true (just space bar)
!!! -> false (exclamation marks cannot be printed by a single line)






code-golf string decision-problem keyboard






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 mins ago

























asked 50 mins ago









Luke Stevens

529112




529112











  • So this is strictly U.S. keyboard layouts? (I've got a UK layout).
    – ouflak
    48 mins ago











  • @ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
    – Luke Stevens
    46 mins ago










  • @Arnauld Yes I did, thanks for noticing!
    – Luke Stevens
    46 mins ago










  • Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
    – ouflak
    45 mins ago











  • Are we allowed to take the input as a list of characters, or does it have to be a string?
    – Kevin Cruijssen
    41 mins ago

















  • So this is strictly U.S. keyboard layouts? (I've got a UK layout).
    – ouflak
    48 mins ago











  • @ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
    – Luke Stevens
    46 mins ago










  • @Arnauld Yes I did, thanks for noticing!
    – Luke Stevens
    46 mins ago










  • Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
    – ouflak
    45 mins ago











  • Are we allowed to take the input as a list of characters, or does it have to be a string?
    – Kevin Cruijssen
    41 mins ago
















So this is strictly U.S. keyboard layouts? (I've got a UK layout).
– ouflak
48 mins ago





So this is strictly U.S. keyboard layouts? (I've got a UK layout).
– ouflak
48 mins ago













@ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
– Luke Stevens
46 mins ago




@ouflak On the contrary, it's strictly only the UK QWERTY keyboard layout
– Luke Stevens
46 mins ago












@Arnauld Yes I did, thanks for noticing!
– Luke Stevens
46 mins ago




@Arnauld Yes I did, thanks for noticing!
– Luke Stevens
46 mins ago












Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
– ouflak
45 mins ago





Yeah I started looking at both and noticed your layout seems to follow the my UK keyboard layout, not my U.S. one. Hmmm... Wonder what my Austrian one looks like in comparison.
– ouflak
45 mins ago













Are we allowed to take the input as a list of characters, or does it have to be a string?
– Kevin Cruijssen
41 mins ago





Are we allowed to take the input as a list of characters, or does it have to be a string?
– Kevin Cruijssen
41 mins ago











4 Answers
4






active

oldest

votes

















up vote
2
down vote














Python 2, 130 123 121 115 bytes





lambda s:any(set(s)<=set(l+l.lower())for l in["`1234567890-=","eqwrtyuiop","ASDFGHJKL;'#","ZXCVBNM,./|<>?"," "])


Try it online!



Naïve approch.






share|improve this answer





























    up vote
    1
    down vote













    Java 10, 169 bytes





    s->int l=0,t;for(var p:s)t=p.matches("[[0-9]`\-=]")?1:"qwertyuiop".contains(p)?2:p.matches("(?i)[asdfghjkl;'#]")?3:p.charAt(0)<33?5:4;l=l<1?t:l!=t?9:l;return l<6;


    Will golf it down from here.



    Try it online.



    Explanation:



    s-> // Method with String-array parameter and boolean return-type
    int l=0, // Line-integer, starting at 0
    t; // Temp integer
    for(var p:s) // Loop over the characters
    t=p.matches("[[0-9]`\-=]")?
    // If it's a character from the first line:
    1 // Set `t` to 1
    :"qwertyuiop".contains(p)?
    // Else-if it's a character from the second line:
    2 // Set `t` to 2
    :p.matches("(?i)[asdfghjkl;'#]")?
    // Else-if it's a character from the third line
    3 // Set `t` to 3
    :p.charAt(0)<33? // Else-if it's a character from the fifth line:
    5 // Set `t` to 5
    : // Else (it must be a character from the fourth line):
    4; // Set `t` to 4
    l=l<1? // If `l` is still 0:
    t // Set it to `t`
    :l!=t? // Else-if `t` is a different line than `l`:
    9 // Set `l` to 9 (non-existing line)
    : // Else (`t` is the same line as `l`):
    l; // Leave `l` the same
    return l<6; // Return whether `l` is not 9





    share|improve this answer




















    • Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
      – Luke Stevens
      7 mins ago


















    up vote
    1
    down vote














    Ruby, 86 bytes





    p /^( *|[d`=-]+|[[]wetyuio-r]+)$/?1:/^([asdfghjkl;'#]+|[\/zxcvbnm,.|<>?]+)$/i?1:0


    Try it online!






    share|improve this answer





























      up vote
      0
      down vote














      Retina 0.8.2, 70 bytes



      ^([-=d]+|[qwertyuiop]+|(?i)[asdfghjkl;'#]+|[\zxcvbnm,./|<>?]+| *)$


      Try it online! Explanation: Each alternation matches a different row of the keyboard. The (?i) in the middle of the pattern causes the entire rest of the pattern to be matched case-insensitively.





      share




















        Your Answer




        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173776%2fone-line-keyboard%23new-answer', 'question_page');

        );

        Post as a guest






























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        2
        down vote














        Python 2, 130 123 121 115 bytes





        lambda s:any(set(s)<=set(l+l.lower())for l in["`1234567890-=","eqwrtyuiop","ASDFGHJKL;'#","ZXCVBNM,./|<>?"," "])


        Try it online!



        Naïve approch.






        share|improve this answer


























          up vote
          2
          down vote














          Python 2, 130 123 121 115 bytes





          lambda s:any(set(s)<=set(l+l.lower())for l in["`1234567890-=","eqwrtyuiop","ASDFGHJKL;'#","ZXCVBNM,./|<>?"," "])


          Try it online!



          Naïve approch.






          share|improve this answer
























            up vote
            2
            down vote










            up vote
            2
            down vote










            Python 2, 130 123 121 115 bytes





            lambda s:any(set(s)<=set(l+l.lower())for l in["`1234567890-=","eqwrtyuiop","ASDFGHJKL;'#","ZXCVBNM,./|<>?"," "])


            Try it online!



            Naïve approch.






            share|improve this answer















            Python 2, 130 123 121 115 bytes





            lambda s:any(set(s)<=set(l+l.lower())for l in["`1234567890-=","eqwrtyuiop","ASDFGHJKL;'#","ZXCVBNM,./|<>?"," "])


            Try it online!



            Naïve approch.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 32 mins ago

























            answered 38 mins ago









            TFeld

            12.2k2834




            12.2k2834




















                up vote
                1
                down vote













                Java 10, 169 bytes





                s->int l=0,t;for(var p:s)t=p.matches("[[0-9]`\-=]")?1:"qwertyuiop".contains(p)?2:p.matches("(?i)[asdfghjkl;'#]")?3:p.charAt(0)<33?5:4;l=l<1?t:l!=t?9:l;return l<6;


                Will golf it down from here.



                Try it online.



                Explanation:



                s-> // Method with String-array parameter and boolean return-type
                int l=0, // Line-integer, starting at 0
                t; // Temp integer
                for(var p:s) // Loop over the characters
                t=p.matches("[[0-9]`\-=]")?
                // If it's a character from the first line:
                1 // Set `t` to 1
                :"qwertyuiop".contains(p)?
                // Else-if it's a character from the second line:
                2 // Set `t` to 2
                :p.matches("(?i)[asdfghjkl;'#]")?
                // Else-if it's a character from the third line
                3 // Set `t` to 3
                :p.charAt(0)<33? // Else-if it's a character from the fifth line:
                5 // Set `t` to 5
                : // Else (it must be a character from the fourth line):
                4; // Set `t` to 4
                l=l<1? // If `l` is still 0:
                t // Set it to `t`
                :l!=t? // Else-if `t` is a different line than `l`:
                9 // Set `l` to 9 (non-existing line)
                : // Else (`t` is the same line as `l`):
                l; // Leave `l` the same
                return l<6; // Return whether `l` is not 9





                share|improve this answer




















                • Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                  – Luke Stevens
                  7 mins ago















                up vote
                1
                down vote













                Java 10, 169 bytes





                s->int l=0,t;for(var p:s)t=p.matches("[[0-9]`\-=]")?1:"qwertyuiop".contains(p)?2:p.matches("(?i)[asdfghjkl;'#]")?3:p.charAt(0)<33?5:4;l=l<1?t:l!=t?9:l;return l<6;


                Will golf it down from here.



                Try it online.



                Explanation:



                s-> // Method with String-array parameter and boolean return-type
                int l=0, // Line-integer, starting at 0
                t; // Temp integer
                for(var p:s) // Loop over the characters
                t=p.matches("[[0-9]`\-=]")?
                // If it's a character from the first line:
                1 // Set `t` to 1
                :"qwertyuiop".contains(p)?
                // Else-if it's a character from the second line:
                2 // Set `t` to 2
                :p.matches("(?i)[asdfghjkl;'#]")?
                // Else-if it's a character from the third line
                3 // Set `t` to 3
                :p.charAt(0)<33? // Else-if it's a character from the fifth line:
                5 // Set `t` to 5
                : // Else (it must be a character from the fourth line):
                4; // Set `t` to 4
                l=l<1? // If `l` is still 0:
                t // Set it to `t`
                :l!=t? // Else-if `t` is a different line than `l`:
                9 // Set `l` to 9 (non-existing line)
                : // Else (`t` is the same line as `l`):
                l; // Leave `l` the same
                return l<6; // Return whether `l` is not 9





                share|improve this answer




















                • Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                  – Luke Stevens
                  7 mins ago













                up vote
                1
                down vote










                up vote
                1
                down vote









                Java 10, 169 bytes





                s->int l=0,t;for(var p:s)t=p.matches("[[0-9]`\-=]")?1:"qwertyuiop".contains(p)?2:p.matches("(?i)[asdfghjkl;'#]")?3:p.charAt(0)<33?5:4;l=l<1?t:l!=t?9:l;return l<6;


                Will golf it down from here.



                Try it online.



                Explanation:



                s-> // Method with String-array parameter and boolean return-type
                int l=0, // Line-integer, starting at 0
                t; // Temp integer
                for(var p:s) // Loop over the characters
                t=p.matches("[[0-9]`\-=]")?
                // If it's a character from the first line:
                1 // Set `t` to 1
                :"qwertyuiop".contains(p)?
                // Else-if it's a character from the second line:
                2 // Set `t` to 2
                :p.matches("(?i)[asdfghjkl;'#]")?
                // Else-if it's a character from the third line
                3 // Set `t` to 3
                :p.charAt(0)<33? // Else-if it's a character from the fifth line:
                5 // Set `t` to 5
                : // Else (it must be a character from the fourth line):
                4; // Set `t` to 4
                l=l<1? // If `l` is still 0:
                t // Set it to `t`
                :l!=t? // Else-if `t` is a different line than `l`:
                9 // Set `l` to 9 (non-existing line)
                : // Else (`t` is the same line as `l`):
                l; // Leave `l` the same
                return l<6; // Return whether `l` is not 9





                share|improve this answer












                Java 10, 169 bytes





                s->int l=0,t;for(var p:s)t=p.matches("[[0-9]`\-=]")?1:"qwertyuiop".contains(p)?2:p.matches("(?i)[asdfghjkl;'#]")?3:p.charAt(0)<33?5:4;l=l<1?t:l!=t?9:l;return l<6;


                Will golf it down from here.



                Try it online.



                Explanation:



                s-> // Method with String-array parameter and boolean return-type
                int l=0, // Line-integer, starting at 0
                t; // Temp integer
                for(var p:s) // Loop over the characters
                t=p.matches("[[0-9]`\-=]")?
                // If it's a character from the first line:
                1 // Set `t` to 1
                :"qwertyuiop".contains(p)?
                // Else-if it's a character from the second line:
                2 // Set `t` to 2
                :p.matches("(?i)[asdfghjkl;'#]")?
                // Else-if it's a character from the third line
                3 // Set `t` to 3
                :p.charAt(0)<33? // Else-if it's a character from the fifth line:
                5 // Set `t` to 5
                : // Else (it must be a character from the fourth line):
                4; // Set `t` to 4
                l=l<1? // If `l` is still 0:
                t // Set it to `t`
                :l!=t? // Else-if `t` is a different line than `l`:
                9 // Set `l` to 9 (non-existing line)
                : // Else (`t` is the same line as `l`):
                l; // Leave `l` the same
                return l<6; // Return whether `l` is not 9






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 20 mins ago









                Kevin Cruijssen

                31.4k553171




                31.4k553171











                • Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                  – Luke Stevens
                  7 mins ago

















                • Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                  – Luke Stevens
                  7 mins ago
















                Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                – Luke Stevens
                7 mins ago





                Nice solution, but it returns true for !!! despite exclamation marks being unable to be printed by any single line. I've just added that as a test case
                – Luke Stevens
                7 mins ago











                up vote
                1
                down vote














                Ruby, 86 bytes





                p /^( *|[d`=-]+|[[]wetyuio-r]+)$/?1:/^([asdfghjkl;'#]+|[\/zxcvbnm,.|<>?]+)$/i?1:0


                Try it online!






                share|improve this answer


























                  up vote
                  1
                  down vote














                  Ruby, 86 bytes





                  p /^( *|[d`=-]+|[[]wetyuio-r]+)$/?1:/^([asdfghjkl;'#]+|[\/zxcvbnm,.|<>?]+)$/i?1:0


                  Try it online!






                  share|improve this answer
























                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote










                    Ruby, 86 bytes





                    p /^( *|[d`=-]+|[[]wetyuio-r]+)$/?1:/^([asdfghjkl;'#]+|[\/zxcvbnm,.|<>?]+)$/i?1:0


                    Try it online!






                    share|improve this answer















                    Ruby, 86 bytes





                    p /^( *|[d`=-]+|[[]wetyuio-r]+)$/?1:/^([asdfghjkl;'#]+|[\/zxcvbnm,.|<>?]+)$/i?1:0


                    Try it online!







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 4 mins ago

























                    answered 21 mins ago









                    Kirill L.

                    2,7961117




                    2,7961117




















                        up vote
                        0
                        down vote














                        Retina 0.8.2, 70 bytes



                        ^([-=d]+|[qwertyuiop]+|(?i)[asdfghjkl;'#]+|[\zxcvbnm,./|<>?]+| *)$


                        Try it online! Explanation: Each alternation matches a different row of the keyboard. The (?i) in the middle of the pattern causes the entire rest of the pattern to be matched case-insensitively.





                        share
























                          up vote
                          0
                          down vote














                          Retina 0.8.2, 70 bytes



                          ^([-=d]+|[qwertyuiop]+|(?i)[asdfghjkl;'#]+|[\zxcvbnm,./|<>?]+| *)$


                          Try it online! Explanation: Each alternation matches a different row of the keyboard. The (?i) in the middle of the pattern causes the entire rest of the pattern to be matched case-insensitively.





                          share






















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote










                            Retina 0.8.2, 70 bytes



                            ^([-=d]+|[qwertyuiop]+|(?i)[asdfghjkl;'#]+|[\zxcvbnm,./|<>?]+| *)$


                            Try it online! Explanation: Each alternation matches a different row of the keyboard. The (?i) in the middle of the pattern causes the entire rest of the pattern to be matched case-insensitively.





                            share













                            Retina 0.8.2, 70 bytes



                            ^([-=d]+|[qwertyuiop]+|(?i)[asdfghjkl;'#]+|[\zxcvbnm,./|<>?]+| *)$


                            Try it online! Explanation: Each alternation matches a different row of the keyboard. The (?i) in the middle of the pattern causes the entire rest of the pattern to be matched case-insensitively.






                            share











                            share


                            share










                            answered 6 mins ago









                            Neil

                            76.3k744173




                            76.3k744173



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173776%2fone-line-keyboard%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                What does second last employer means? [closed]

                                List of Gilmore Girls characters

                                Confectionery