On Sun, May 14, 2017 at 6:02 PM, anatoly techtonik <techto...@gmail.com> wrote:
> On Fri, May 12, 2017 at 7:54 AM, Nigel Tao <nigel...@golang.org> wrote:
>> On Fri, May 12, 2017 at 3:11 AM, anatoly techtonik <techto...@gmail.com> 
>> wrote:
>>> I am new to Go and I need a cross-platform value for keyboard key codes to
>>> make sure I can react to user key presses regardless of operating system
>>> layer.
>>
>> FYI, there's already the key.Code type defined in
>> https://github.com/golang/mobile/blob/master/event/key/key.go
>
> 1. So does that mean it will conflict if both are imported?
>
> Right now https://github.com/yakshaveinc/go-keycodes/blob/master/keycodes.go
> uses KeyF11 while mobile lib uses CodeF11. For me Code is less clear
> than Key, because from user point of view they press keys, not
> symbols/characters of codes.

It will not conflict.

As for names, note that users of that package will refer to it by its
qualified name: key.CodeF11, not a bare CodeF11.

For example, with the net/http package in the standard library, the
types are called Client and Server, which users of that package will
see as http.Client and http.Server. It's not "type HTTPClient" which
would become "http.HTTPClient". Even so, http.Client and rpc.Client
(from the net/rpc package) will not conflict.


> 2. Does it provide reverse mapping, so that if user press F11, go
> program could write "KeyF11" to console?

Yes, just call the String method, or just pass it to e.g. fmt.Printf("%v", etc).


> 3. How should keycodes package be renames and placed so that I could
> be reused in mobile?

I'm not sure that it needs to be renamed, or that you need a new
package. It might be fine for golang.org/x/term code to import
golang.org/x/mobile packages.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to