Home Download Buy Blog Forum Support

Issue with Key Binding

Issue with Key Binding

Postby dom111 on Tue Jun 14, 2011 11:01 am

Hi there,

I'm trying to bind " ctrl+shift+' " on Windows (XP), but it doesn't appear to be working, is there a known issue with using the single quote key, or does it relate to keyboard layouts?

Apologies if this has been answered elsewhere, I did have a quick search, but couldn't see anything obvious!

Thanks in advance,

Dom
dom111
 
Posts: 12
Joined: Wed Jun 08, 2011 9:13 am
Location: UK

Re: Issue with Key Binding

Postby rchl on Tue Jun 14, 2011 4:49 pm

Assuming that you use American keyboard layout, you could try if key-binding with double-quote character works. Ultimately, if you are holding shift, you trigger double quote, not single quote so it makes sense that your binding doesn't work.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

Re: Issue with Key Binding

Postby jps on Tue Jun 21, 2011 4:33 am

ctrl+shift+' is working for me (Windows 7). Specifically, this is the key binding file I tried:

Code: Select all
[
   { "keys": ["ctrl+shift+'"], "command": "select_all" }
]


Keyboard layouts can prevent this from working, if they don't specify any keys mapping to the virtual key code 0xDE. If you aren't getting any luck with the above, try temporarily switching to a US keyboard layout and see if that's working for you.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Issue with Key Binding

Postby dom111 on Tue Jun 21, 2011 5:45 am

Thanks both. I have tried using ctrl+shift+', ctrl+shift+@ and ctrl+shift+" to no avail. Also, as to switching to US keyboard layout, sometimes Sublime seems to act like it's using a US keyboard layout, and when it does, that ctrl+shift+' key command works... I haven't mentioned it as a bug, since it's quite beneficial to me, but it certainly happens sometimes, when it does, quitting and restarting gets it back to standard (UK) layout but the shortcut stops working :(.

If you'd like some more debug info on the keyboard layout, let me know (you may have to tell me how to get it ;P)
dom111
 
Posts: 12
Joined: Wed Jun 08, 2011 9:13 am
Location: UK

Re: Issue with Key Binding

Postby jps on Tue Jun 21, 2011 8:17 am

The UK keyboard layout assigns the "'/@" key a virtual key code of 0xC0 (aka VK_OEM_3), which is used for the "`/~" key on the US keyboard layout. Consequently, you can bind to it using the ` character. Sublime Text's key binding system on windows is based around virtual key codes, rather than emitted characters. It means some issues such as this are unavoidable, but is overall a net win.

If your keyboard layout is changing for you at random, then it may be that you have a key sequence defined (in Region and Language settings in the control panel) that changes between them - IIRC this happens by default.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Issue with Key Binding

Postby iamntz on Tue Jun 21, 2011 8:31 am

There is a way of defining multiple keys based on scope type?
I mean if the file type is html, when i press ctrl+b the selection to be wrapped lie this

Code: Select all
   {
      "keys": ["ctrl+b"],
      "command": "insert_snippet",
      "args"   :   {
         "contents": "<strong>${1:$SELECTION}</strong>"
      }
   }

But if is ... let's say css, to insert font-weight:700

I tried to do like this:
Code: Select all
"keys": ["ctrl+b", "ctrl+g"],

with no luck.

Also, i tried to add:
Code: Select all
"scope":"html"


In (or out) args with no luck.

Make sense or i'm rambling? :D
iamntz
 
Posts: 918
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Issue with Key Binding

Postby bizoo on Tue Jun 21, 2011 9:02 am

Something like this ?

Code: Select all
[
   { "keys": ["alt+o"], "command": "switch_file", "args": {"extensions": ["pas", "dfm"]}, "context":
      [
         { "key": "selector", "operator": "equal", "operand": "source.pascal" }
      ]
   },
   { "keys": ["alt+o"], "command": "switch_file", "args": {"extensions": ["pks", "pkb"]}, "context":
      [
         { "key": "selector", "operator": "equal", "operand": "source.sql" }
      ]
   }
]
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Issue with Key Binding

Postby iamntz on Tue Jun 21, 2011 9:34 am

Pffff!
That's it!

Thanks a lot! :mrgreen:
iamntz
 
Posts: 918
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 10 guests